lundi 27 mars 2017

AWS s3 image url 404 error in img tag

Strange problem!!

I am trying to display an image in my laravel application after an ajax call.

 $.ajax({
                url:$(this).attr('action'),
                method:"post",
                processData:false,
                contentType: false,
                data:data,
                success:function (data) {
                   console.log(data.url);
                   $('#cropped-image').attr('src', encodeURI(data.url));

                 }

But i got 404 error in console however when i open the url in browser it will download the image.

Image is upload via s3 direct browser upload

<form id="upload" action="//s3-us-west-2.amazonaws.com/lambdacushbu" method="POST" enctype="multipart/form-data">

    <input type="hidden" name="Content-Type" value="" />
<input type="hidden" name="acl" value="private" />
<input type="hidden" name="success_action_status" value="201" />
<input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNy0wMy0yN1QxNDozODoyMloiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJsYW1iZGFjdXNoYnUifSx7ImFjbCI6InByaXZhdGUifSxbInN0YXJ0cy13aXRoIiwiJGtleSIsIiJdLFsic3RhcnRzLXdpdGgiLCIkQ29udGVudC1UeXBlIiwiIl0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1MjQyODgwMDBdLHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn0seyJ4LWFtei1jcmVkZW50aWFsIjoiQUtJQUpVNDVUN1VXU1hCR1NZSUFcLzIwMTcwMzI3XC91cy13ZXN0LTJcL3MzXC9hd3M0X3JlcXVlc3QifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWRhdGUiOiIyMDE3MDMyN1QwODM4MjJaIn1dfQ==" />
<input type="hidden" name="X-amz-credential" value="AKIAJU45T7UWSXBGSYIA/20170327/us-west-2/s3/aws4_request" />
<input type="hidden" name="X-amz-algorithm" value="AWS4-HMAC-SHA256" />
<input type="hidden" name="X-amz-date" value="20170327T083822Z" />
<input type="hidden" name="X-amz-signature" value="2b89cf3b21de2a118f24c0f9b8463025615d302f86ee85047adc9bbf0cccee97" />
<input type="hidden" name="key" value="${filename}" />
    <input type="file" name="file" id="image">
    <br>
    <input type="submit" value="upload" name="upload">
        <span id="status-text"></span>
</form>

anonymous read permission is added to the bucket policy page



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mHjZYC
via IFTTT

Aucun commentaire:

Enregistrer un commentaire