通过互联网发送NSData
。发送的数据长度为 8278 字节。但收到的数据仅为 8029 字节。你知道为什么数据被服务器截断了吗?是数据大小的HTTP / TCP限制吗?或者是node.js
限制?
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
let path = (documentsPath.stringByAppendingPathComponent("Assets") as NSString).stringByAppendingPathComponent("\(upsert.recordName).\(field2.key)")
let url: NSURL = NSURL(string: "xxx")!
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.setValue("image/jpg", forHTTPHeaderField: "content-type")
request.setValue("\(upsert.recordName).\(field.key)", forHTTPHeaderField: "filename")
request.HTTPBody = NSData(contentsOfFile: path)
NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()).dataTaskWithRequest(request, completionHandler: {data, urlResponse, error in }).resume()
答案 0 :(得分:0)
删除
request.setValue("image/jpg", forHTTPHeaderField: "content-type")
行将阻止减少和转换内容。