我正在使用https://github.com/odysseyscience/react-s3-uploader并且它一直很好用。我上传了大量不同的文件等等,但它很好 - 但突然开始失败的视频出现错误:net :: ERR_CONNECTION_RESET
我使用此
指定网址 String ext = objectName.substring(objectName.lastIndexOf('.') + 1,objectName.length()).toLowerCase();
GeneratePresignedUrlRequest generatePresignedUrlRequest
= new GeneratePresignedUrlRequest(showhowBucket, "assets/" + objectName , HttpMethod.PUT);
switch(ext){
case "png":
generatePresignedUrlRequest.withContentType("image/png");
break;
case "jpg":
generatePresignedUrlRequest.withContentType("image/jpg");
break;
case "jpeg":
generatePresignedUrlRequest.withContentType("image/jpg");
break;
case "mp4":
generatePresignedUrlRequest.withContentType("video/mp4");
break;
case "mp3":
generatePresignedUrlRequest.withContentType("audio/mp3");
break;
case "m4u":
generatePresignedUrlRequest.withContentType("audio/mpeg");
break;
case "zip":
generatePresignedUrlRequest.withContentType("application/x-zip-compressed");
break;
}
// setting additional params: expiration date , content-type, etc
long expiration = System.currentTimeMillis() + 36000000;
generatePresignedUrlRequest.withExpiration(new Date(expiration));
generatePresignedUrlRequest.addRequestParameter(
Headers.S3_CANNED_ACL,
CannedAccessControlList.PublicRead.toString()
);
// finally generating URL string
URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);
这是我的S3Uploader参数
const uploader = new S3Upload({
getSignedUrl: getSignedUrl,
uploadRequestHeaders: {'x-amz-acl': 'public-read'},
contentType: contentType,
scrubFilename: (filename) => filename.replace(/[^\w\d_\-.]+/ig, ''),
contentDisposition: 'auto',
s3path: 'assets/',
onError:reject,
onFinishS3Put: resolve,
})
uploader.uploadFile(file)
如上所述,对于图像,zip文件等来说这很好。只是在视频上超时。