|
@@ -63,9 +63,7 @@ func UpLoadByRestful(domain, bucketId, objectName string, stream []byte, gzip bo
|
|
* @param domain 域名,例如:https://ossservice.jianyu360.cn
|
|
* @param domain 域名,例如:https://ossservice.jianyu360.cn
|
|
* @param bucketId 桶id
|
|
* @param bucketId 桶id
|
|
* @param objectName 对象名称
|
|
* @param objectName 对象名称
|
|
- * @param fileBt 文件流
|
|
|
|
- * @param gzip 是否压缩
|
|
|
|
- * @return {"error_code":0,"error_msg":"上传成功"}
|
|
|
|
|
|
+ * @return {"error_code":0,"error_msg":"下载成功"}
|
|
*/
|
|
*/
|
|
func DownloadByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
func DownloadByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
reply = &api.Result{}
|
|
reply = &api.Result{}
|
|
@@ -77,6 +75,7 @@ func DownloadByRestful(domain, bucketId, objectName string) (reply *api.Result)
|
|
if respBody, err := post(domain+constant.DownloadUrl, writer, body); err != nil {
|
|
if respBody, err := post(domain+constant.DownloadUrl, writer, body); err != nil {
|
|
reply.Error_msg = err.Error()
|
|
reply.Error_msg = err.Error()
|
|
} else {
|
|
} else {
|
|
|
|
+ reply.Error_msg = constant.DownloadSuccess
|
|
reply.Data = respBody
|
|
reply.Data = respBody
|
|
}
|
|
}
|
|
return
|
|
return
|
|
@@ -86,8 +85,6 @@ func DownloadByRestful(domain, bucketId, objectName string) (reply *api.Result)
|
|
* @param domain 域名,例如:https://ossservice.jianyu360.cn
|
|
* @param domain 域名,例如:https://ossservice.jianyu360.cn
|
|
* @param bucketId 桶id
|
|
* @param bucketId 桶id
|
|
* @param objectName 对象名称
|
|
* @param objectName 对象名称
|
|
- * @param fileBt 文件流
|
|
|
|
- * @param gzip 是否压缩
|
|
|
|
* @return {"error_code":0,"error_msg":"上传成功"}
|
|
* @return {"error_code":0,"error_msg":"上传成功"}
|
|
*/
|
|
*/
|
|
func DeleteByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
func DeleteByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
@@ -105,6 +102,28 @@ func DeleteByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* restful方式获取标讯正文
|
|
|
|
+ * @param domain 域名,例如:https://ossservice.jianyu360.cn
|
|
|
|
+ * @param bucketId 桶id
|
|
|
|
+ * @param objectName 对象名称
|
|
|
|
+ * @return {"error_code":0,"error_msg":"获取正文成功","data":"正文内容"}
|
|
|
|
+ */
|
|
|
|
+func GetBidDetailByRestful(domain, bucketId, objectName string) (reply *api.Result) {
|
|
|
|
+ reply = &api.Result{}
|
|
|
|
+ // 创建一个缓冲区来存储表单数据
|
|
|
|
+ body := &bytes.Buffer{}
|
|
|
|
+ writer := multipart.NewWriter(body)
|
|
|
|
+ writer.WriteField("bucket_id", bucketId)
|
|
|
|
+ writer.WriteField("object_name", objectName)
|
|
|
|
+ if respBody, err := post(domain+constant.GetBidDetailUrl, writer, body); err != nil {
|
|
|
|
+ reply.Error_msg = err.Error()
|
|
|
|
+ } else {
|
|
|
|
+ reply.Error_msg = constant.GetBidDetailSuccess
|
|
|
|
+ reply.Data = string(respBody)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
func post(url string, writer *multipart.Writer, body *bytes.Buffer) ([]byte, error) {
|
|
func post(url string, writer *multipart.Writer, body *bytes.Buffer) ([]byte, error) {
|
|
// 关闭表单写入器
|
|
// 关闭表单写入器
|
|
if err := writer.Close(); err != nil {
|
|
if err := writer.Close(); err != nil {
|
|
@@ -183,6 +202,21 @@ func DeleteByRpc(address string, args *entity.Args) (api.Result, error) {
|
|
err := rpcCall(address, "OSSService.Delete", args, &reply)
|
|
err := rpcCall(address, "OSSService.Delete", args, &reply)
|
|
return reply, err
|
|
return reply, err
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ *rpc方式获取标讯正文
|
|
|
|
+ * @param address 域名,例如:192.168.3.206:8110
|
|
|
|
+ * @param args 参数
|
|
|
|
+ * @param args.BucketID 文件名
|
|
|
|
+ * @param args.objectName 对象名称
|
|
|
|
+ * @return {"error_code":0,"error_msg":"下载成功","data":"正文内容"}
|
|
|
|
+ * @return error 错误信息
|
|
|
|
+ */
|
|
|
|
+func GetBidDetailByRpc(address string, args *entity.Args) (api.Result, error) {
|
|
|
|
+ var reply api.Result
|
|
|
|
+ err := rpcCall(address, "OSSService.GetBidDetail", args, &reply)
|
|
|
|
+ return reply, err
|
|
|
|
+}
|
|
func rpcCall(address, serviceMethod string, args any, reply any) error {
|
|
func rpcCall(address, serviceMethod string, args any, reply any) error {
|
|
client, err := rpc.DialHTTP("tcp", address)
|
|
client, err := rpc.DialHTTP("tcp", address)
|
|
if err != nil {
|
|
if err != nil {
|