朋友仇敌_个人页

个人头像照片 朋友仇敌
0
2
0

个人介绍

暂无个人介绍

擅长的技术

获得更多能力
通用技术能力:

暂时未有相关通用技术能力~

云产品技术能力:

暂时未有相关云产品技术能力~

阿里云技能认证

详细说明
暂无更多信息
正在加载, 请稍后...
暂无更多信息
  • 提交了问题 2017-08-16

    此帖子作废 OSS上传回调

  • 回答了问题 2017-08-16

    OSS callback功能常见问题分析

    回 1楼xgp的帖子 楼主求帮助啊!能不能帮忙看看这个问题: 最近在做OSS文件上传回调,直接用的.Net SDK中的上传回调代码 这是我的代码: public void PutObjectCallback(string bucketName)         {             var client = new OssClient(endpoint, accessKeyId, accessKeySecret, securityToken);             string key = 'my_key;               string callbackUrl = 'myUrl';             string callbackBody = 'bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&' +                                 'patient_name=${x:var1}&patient_id=${x:var2}';             try             {                 string responseContent = '';                 var metadata = BuildCallbackMetadata(callbackUrl, callbackBody);                 using (var fs = File.Open(fileToUpload, FileMode.Open))                 {                     var putObjectRequest = new PutObjectRequest(bucketName, key, fs, metadata);                     var result = client.PutObject(putObjectRequest);                     responseContent = GetCallbackResponse(result); //返回值一直是verify not ok                 }                 LightMessage MsgInfo = new LightMessage() { Light = LightType.Red, Message = '文件上传成功' + responseContent, Time = DateTime.Now };                 StoreSCPMainForm.thisForm.Addmsg(MsgInfo);             }             catch (OssException ex)             {                 LightMessage MsgInfo = new LightMessage() { Light = LightType.Red, Message = '文件上传回调异常' + ex.ToString(), Time = DateTime.Now };                 StoreSCPMainForm.thisForm.Addmsg(MsgInfo);                 logMsg.WriteLog(new LogItem(LogType.Warnning, ex.ToString()));             }             catch (Exception ex)             {                 LightMessage MsgInfo = new LightMessage() { Light = LightType.Red, Message = '文件上传回调初始化失败' + ex.ToString(), Time = DateTime.Now };                 StoreSCPMainForm.thisForm.Addmsg(MsgInfo);                 logMsg.WriteLog(new LogItem(LogType.Warnning, ex.ToString()));             }         }         private string GetCallbackResponse(PutObjectResult putObjectResult)         {             string callbackResponse = null;             using (var stream = putObjectResult.ResponseStream)             {                 var buffer = new byte[4 * 1024];                 var bytesRead = stream.Read(buffer, 0, buffer.Length);                 callbackResponse = Encoding.Default.GetString(buffer, 0, bytesRead);             }             return callbackResponse;         }         private ObjectMetadata BuildCallbackMetadata(string callbackUrl, string callbackBody)         {             string callbackHeaderBuilder = new CallbackHeaderBuilder(callbackUrl, callbackBody).Build();             string CallbackVariableHeaderBuilder = new CallbackVariableHeaderBuilder().                 AddCallbackVariable('x:var1', 'x:tangliang').AddCallbackVariable('x:patient_id', 'x:000000').Build();             var metadata = new ObjectMetadata();             metadata.AddHeader(HttpHeaders.Callback, callbackHeaderBuilder);             metadata.AddHeader(HttpHeaders.CallbackVar, CallbackVariableHeaderBuilder);             return metadata;         } 单独上传是成功的,但是上传回调总是报错:{'Status':'verify not ok'},还请指教!是我的callbackBody拼接不正确,还是其他原因?
    踩0 评论0
正在加载, 请稍后...
滑动查看更多
正在加载, 请稍后...
暂无更多信息