开发者社区> 问答> 正文

关于.NETSDKPutObject上传文件时间超时的问题

问题:
      利用PutObjec上传本地的一个272KB文件,调用时IE一直在Loading,然后报 操作超时异常。
根据SDK文档编写的代码 :
try
                    {
                        //上图片到阿里云
                        String accessId = "******";
                        String accessKey = "******";
                        String endPoint = "http://oss-cn-beijing.aliyuncs.com";
                        OssClient ossClient = new OssClient(endPoint, accessId, accessKey);
                        using (var fs = File.Open("d:\\a.jpg", FileMode.Open))
                        {
                            // 可以设定自定义的metadata。
                            ObjectMetadata metadata = new ObjectMetadata();
                            metadata.ContentLength = fs.Length;
                            metadata.ContentType = "image/jpeg";
                            ossClient.PutObject("fires", "thum/original/2014/5/a.jpg", fs, metadata);
                        }
                    }
                    catch (OssException ex)
                    {

                    }

根据快速入门手册的编写的 代码:
FileStream fs = File.Open("D:\\20140530100839140.jpg", FileMode.Open);
                // 可以设定自定义的metadata。
                ObjectMetadata metadata = new ObjectMetadata();
                //metadata.ContentLength = fs.Length;
                //metadata.ContentType = "image/jpeg";
                metadata.UserMetadata.Add("myfield","test");
                PutObjectResult result = client.PutObject(bucket, "20140530100839140.jpg", fs, metadata);


异常:
[WebException: 操作超时]
   Aliyun.OpenServices.Common.Communication.RetryableServiceClient.SendImpl(ServiceRequest request, ExecutionContext context, Int32 retries) in d:\Work\API\openapi\dotnet\aliyunapi\Common\Communication\RetryableServiceClient.cs:82
   Aliyun.OpenServices.Common.Communication.RetryableServiceClient.Send(ServiceRequest request, ExecutionContext context) in d:\Work\API\openapi\dotnet\aliyunapi\Common\Communication\RetryableServiceClient.cs:54
   Aliyun.OpenServices.OpenStorageService.Commands.OssCommand.Execute() in d:\Work\API\openapi\dotnet\aliyunapi\OpenStorageService\Commands\OssCommand.cs:76
   Aliyun.OpenServices.OpenStorageService.Commands.OssCommand`1.Execute() in d:\Work\API\openapi\dotnet\aliyunapi\OpenStorageService\Commands\OssCommand.cs:125
   Aliyun.OpenServices.OpenStorageService.OssClient.PutObject(String bucketName, String key, Stream content, ObjectMetadata metadata) in d:\Work\API\openapi\dotnet\aliyunapi\OpenStorageService\OssClient.cs:319
   PhotoAlbum.ProcessPhoto(String originalImagePath, String thumbnailPath, Int32 width, Int32 height) in D:\Project\FitGpsServer\FitGpsServer\PhotoAlbum.ascx.cs:500
   PhotoAlbum.Page_Load(Object sender, EventArgs e) in D:\Project\FitGpsServer\FitGpsServer\PhotoAlbum.ascx.cs:62
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627






展开
收起
极光_t 2015-01-13 17:05:27 9368 0
1 条回答
写回答
取消 提交回答
  • Re关于.NETSDKPutObject上传文件时间超时的问题
    已解决,换公网环境测试通过,可能和公司网关限制有关。
    2015-01-15 11:02:38
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
从 SDK 到编解码:视频直播架构解析 立即下载
跨平台的云服务SDK需要什么 立即下载
一个跨平台的云服务SDK需要什么 立即下载