我们创建了一个可以将多个图像上传到服务器的应用程序(PHP REST API),但上传需要更多时间,如果我将10个图像添加到队列,那么应用程序正在慢慢响应
我们看到Facebook iOS应用程序可以轻松上传多张图片(试过32张),并在15秒内上传
他们如何设法将图片快速上传到服务器以及他们如何在应用手机内存中管理它
在将其上传到服务器之前,它们会降低质量吗?
服务器和应用的规格:
xCode:7.3
用于上传图片的Alamofire [多部分] - API调用
PHP:5.5.9-1
Apache2:2.4.7
MySQL:5.5.49-0
PHP配置:
memory_limit:512M
max_file_uploads:100
post_max_size:512M
max_execution_time:600
upload_max_filesize:512M
图片上传代码
manager.upload(.POST, CustomizedEP,
multipartFormData: { multipartFormData in
if let imageData = UIImageJPEGRepresentation(profilePic, 1) {
multipartFormData.appendBodyPart(data: imageData, name: "temp_pic", fileName: imageName, mimeType: "image/png")
}
for (key, value) in ["image_name": imageName] {
multipartFormData.appendBodyPart(data: value.dataUsingEncoding(NSUTF8StringEncoding)!, name: key as! String)
}
},
encodingCompletion: { encodingResult in
switch encodingResult {
case .Success(let upload, _, _):
upload.responseJSON { response in
if let data = response.result.value {
self.delegate.addPicToPostResponse!(data, Status: (response.response?.statusCode)!);
hideLoader(LoaderType.Default);
}
}
upload.progress{ _, totalBytesRead, totalBytesExpectedToRead in
//let progress = Float(totalBytesRead)/Float(totalBytesExpectedToRead);
//self.delegate.uploadTempPicProgressInfo!(progress, index: index, request: upload.request!); //Removed index so we are not using it
}
case .Failure(let encodingError):
print(encodingError)
hideLoader(LoaderType.Default);
}
});
我们正在上传iPhone5拍摄的图片