hello one and all, i'm in a nightmare trying to upload files via pure client-side javascript to aws s3 using, i guess, aws-sdk-js. perhaps someone out there who's done this can have a discussion with me and i don't know where else to go. i know this isn't web2py but i'm in the weeds on this one and pretty damn frustrated. alright, here is my code under the view under the head block which goes under the header of the html page as assembled by web2py: {{block head}} <script src="https://sdk.amazonaws.com/js/aws-sdk-2.283.1.min.js"></script> <script> const bucketName = 'bucketXYZ'; const bucketRegion = 'us-east-1';
var s3 = new AWS.S3({ params: { Bucket: bucketName }, region: bucketRegion, accessKeyId : 'someKeyId', secretAccessKey : 'someAccessKey' }); function local_file_upload(event) { event.preventDefault(); var e = jQuery('input[type="file"]'); var file = e.prop('files')[0]; var filename = file.name; console.log('uploading file: '+filename); var folder = encodeURIComponent('foldername'+'/'+filename); s3.upload({ Key: folder, Body: file, ACL: 'public-read' }, function(error, data) { if (error) { return alert('Upload Error: ', error.message); } alert('Upload Successfull'); }); } {{end}} i'm crazy because all of the examples are spread all over hell and some have similar code but then mix in a thing called node.js and hence a require('aws-sdk') which i can't figure out if node.js is a client side javascript file because it seems to get installed on the server. anyway, i may not need node.js at all and would prefer to stay with the min.js file, as in the above code. at this point, i'm not worried about just using the access and secret keys as a straight string, i know to protect it later with an ajax request to the server and hide the keys in the code. the s3 variable doesn't error. only when i run the local_file_update function. it throws the error: Failed to load resource: Preflight response is not successful. anyway, if anyone has an idea and can guide me, i would really appreciate the help. thank you, lucas -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c7ea3f90-ddb5-4fba-bc4b-ff10a5608f5d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.