Upload Files directly to Amazon S3 bucket the progress bar is not working correctly using Laravel 5
Hi i am exploring the Github but i am seeing that people are facing some issues while uploading files to Amazon S3 Bucket. So can some one please let me know if dropzone js supports the Amazon S3 file upload yet...? If it supports the S3 then kindly please take a look at my code see why the progress bar of Dropzone js is not working correctly.
Here is the Case when ever i upload file directly to the Amazon S3 Bucket using dropzone then the progress bar quickly reaches 100% mean while the file is still uploading on the Amazon S3 bucket. Here is my code
```
Dropzone.autoDiscover = false;
myDropzone = new Dropzone("div#dropzoneFileUpload", {
url: baseUrl + "/challenge/store",
success : function(file, response){
alert('success')
},
error : function(file, response){
this.removeAllFiles()
},
uploadProgress: function(progress) {
// The event does not work when ever file is select it say 100 in alert
alert(progress);
document.querySelector("#total-progress .progress-bar").style.width = progress + "%";
},
autoProcessQueue: false,
maxFiles: 1,
maxFilesize: 20480, // MB
addRemoveLinks: true,
acceptedFiles: "video/*,mp4,.mkv,.avi,.flv,.3gp,.mov,.wmv,.webm",
params: {
_token: token,
}
});
I am using Php Laravel on server side i am not putting file on my server i am directly uploading the file to Amazon S3 Bucket Here is my Laravel Code
$file = $request->file( 'file' );
$s3 = \Storage::disk('s3');
$filePath = '/buckVideo/' . $name;
$isS3VideoUpload = $s3->put($filePath, file_get_contents($file), 'public');
the file is successfully uploaded to Amazon S3 bucket but progress bar is not working correctly.It goes to 100% directly in an instant.While the server takes time give the response..
@usamamashkoor . Did you find a solution to that problem ? I have the same one
@quaidesbalises i am not using it now i have developed my own script for this purpose... using jquery ajax native functions...
Same problem...
same here!
anyone got solution for this?
Same problem here ? Any news ?
I have used the amazon s3 Javascript Browser SDK for the progress bar upload. You can check the more details about it here. https://aws.amazon.com/sdk-for-browser/
I have error- Access to XMLHttpRequest at 'https://4kd2hi3ere.execute-api.us-east-1.amazonaws.com/default/myfirstvuecode' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how to solve this error
In amazon S3, you need to setup a CORS configuration to allow for all hosts whilst you are testing on localhost. I usually open up everything in development mode when i hit an issue. That way i can tell if its a client issue or an S3 access issue. e.g.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
<ExposeHeader>ETag</ExposeHeader>
</CORSRule>
</CORSConfiguration>
Once in production, this should be restricted to only the the origin(s) and method(s) required.
@rhnetig its not working still getting error please suggest.
@rhnetig as you suggested above configuration i changes CORSConfiguration having following errors
At front end-
Access to XMLHttpRequest at 'https://4kd2hi3ere.execute-api.us-east-1.amazonaws.com/default/myfirstvuecode' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
lambda.js?ba28:16 Error: Network Error
at createError (eval at
And in CloudWatch - 05:21:52 START RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad Version: $LATEST START RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad Version: $LATEST 05:21:52 END RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad END RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad 05:21:52 REPORT RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad Duration: 225.02 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 33 MB REPORT RequestId: 26c51933-b1e7-43a9-be6d-5b34e70989ad Duration: 225.02 ms Billed Duration: 300 ms Memory Size: 128 MB Max Memory Used: 33 MB
Please help.