简体   繁体   中英

issue in uploading large files to aws s3 through browser using aws-sdk

With the help of this blog http://www.cheynewallace.com/uploading-to-s3-with-angularjs/ I did manage to upload the files of smaller size (<30MB) to the s3 bucket. But while uploading a bit larger file (above 30MB) I am facing some issue.

error:Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at 'https://s3.amazonaws.com/**' (Reason: CORS request failed).

I am getting this error in the middle of file uploading ie,initially it starts uploading,but later (say after 15% or 18% uploaded) it is firing the CORS error and the uploading of file again starts from 0%

I am very new to AWS S3. Please correct me if I am asking anything wrong.

This issue is common issue while uploading large files on amazon s3. Recommended way for upload large files to amazon is divide your large files into small chunks. For uploading files, you can use this angular library. and for divide your files into chunks, you can follow this sample example. . I hope, this will help you.

this is probably because your CORS policy needs more permission on larger files. set console.log() and Press CTRL + SHIFT + J, on the key board and check the console for errors. If its the CORS needing more permission it would say something like failed POST or failed DELTE. Whatever one it says add it to your buckets CORS policy like such:

[
{
    "AllowedHeaders": [
        "*"
    ],
    "AllowedMethods": [
        "GET",
        "PUT",
        "POST",
        "DELETE"
    ],
    "AllowedOrigins": [
        "*"
    ],
    "ExposeHeaders": [
        "Access-Control-Allow-Origin"
    ]
}

]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM