"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
|