分享

C# 对于含有中文名字的文件上传到swift不成功!!!!

WoAiCheDan 发表于 2013-10-17 21:29:04 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 4 7743
"Error: http://192.168.1.234:1910/v1/AUTH_79da64e49d5249b7aa4f3d64991aafdd/年后 Unable to PUT InternalServerError" 返回 500的内部服务器错误。
swift对于object名字的约束是这样的:
Object名称约束
1.不能包含保留字符。官方文档上如是说,但没说哪些是保留字符,源码里也没找到 -。-;
2.经过UTF-8的URL-Encoded之后的字节
            /// Puts the object.
            ///
            ///
            /// A
            ///
            ///
            /// The storage Url
            ///
            ///
            /// The Auth Token
            ///
            ///
            /// The container name
            ///
            ///
            /// The name of the object
            ///
            ///
            /// The contents of the object
            ///
            ///
            /// Any custom headers needed for the request
            ///
            ///
            /// Any custom query strings needed for the request
            ///
            public override ObjectResponse PutObject(string url, string token, string container, string name, Stream contents, Dictionary headers, Dictionary query)
                {
                        var total_length = 0;
                        headers["X-Auth-Token"] = token;
                        var request = _http_factory.GetHttpRequest("PUT", url + '/' + _encode(container) + '/' + _encode(name), headers, query);
                        request.AllowWriteStreamBuffering = false;
                        //Default Content Length is -1 if one is not set.
                        //Lets Chunk Dat Body yo.
                        if (request.ContentLength == -1)
                        {
                                request.SendChunked = true;
                        }
                        var req_stream = request.GetRequestStream();
                        var buff = new byte[ChunkSize];
                        const int offset = 0;
                int read;
                        while((read = contents.Read(buff, offset, ChunkSize)) > 0)
                        {
                            if (Progress != null)
                            {
                                        total_length += read;
                                        Progress(total_length);
                            }
                                req_stream.Write(buff, offset, read);
                        }
                        if (OperationComplete != null)
                        {
                                OperationComplete();
                        }
                        req_stream.Close();
                        contents.Close();
            var response = request.GetResponse();
                        response.Close();
                        return new ObjectResponse(response.Headers, response.Reason, response.Status, null);
                }
在swift日志中是这样的错误记录,但是别人都是这样用的,我又不能说是swift源码的错


这个问题困扰了我几天了,因为查不出原因,忘那个大神指点指点。
分不多,希望见谅!!!
              
               
                    Swift
                    C#
                    URL
                    对象
                    String
               

已有(4)人评论

跳转到指定楼层
WoAiCheDan 发表于 2013-10-17 21:29:46

            求大神顶!!!!
        
回复

使用道具 举报

WoAiCheDan 发表于 2013-10-17 21:30:20

            算了,自己解决了,一百分也没有人来回。。。。。
        
回复

使用道具 举报

lts9165 发表于 2013-10-17 21:30:55

            我也遇到了这个问题,请问LZ你是如何解决的?
        
回复

使用道具 举报

zvcxafdsqrew 发表于 2013-10-17 21:31:29

            我也遇到了这个问题,请问LZ你是如何解决的?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条