File upload to aws s3 bucket doesnt work on server

I’m trying to upload files like png to my aws s3 bucket,
on Client side I can manage to upload it successfully using aws-sdk package
however when I pass the file object down to server I receive {} empty object

client side onFinish function =>

const onFinish = (values) => {
       const file = document.getElementById('inputFile').files[0];
       console.log(file) // consoles all file details before calling method
             Meteor.call('png.upload', file, (error, result) => {
                     if(error){
                          //console error
                       }
             }
}

and on server side i got this simple console to see if im getting data

 'png.upload'(file) {

    console.log(file) // consoles {}
}

any idea how i can pass over file object from client to server?

Hi,

I’m sorry I’m not helping you at all but there’s a question I have for you.

On the client side, do you use it in a cordova app as well or only web clients ?

If it’s a cordova app, could you describe how you included the aws-sdk package without making the app bundle 7mb bigger ?

Regards,

Burni

@cloudiy the concept seems … not so efficient.
You may have a look at this: s3up - npm and this conversation: File Uploads - edgee:slingshot - still good? better options? - #20 by rijk

You don’t need to send the file to the server unless you want to write it in your MongoDB which you shouldn’t do. It is possible but not efficient nor cheap. Client uploads directly to cloud storage.

If you need a high degree of privacy/confidentiality you can go for GitHub - veliovgroup/Meteor-Files: 🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.. You can also do signed URLs or just public files and deliver via CDN.

1 Like

I want to pass the file thats what i want to see, that when i console log the file it shows all attributes of the file just like on client side,
For me I want to understand the issue, why when i send a simple string it passes

but a FILE object does not pass

It’s not a cordova app, it just bugs me to not being able to understand the issue

seems like no one even tried this before, i pass a simple string it passes to meteor method

but when I pass a FILE object over from client to server, nothing is passed…

To be frank I am not really sure what you want to send to the server. Your file object is a constructor, does not contain your actual file. While it is true that you have to pass an object to your Meteor method, I am not sure this is the right object.
Try something like this and see if you get your data:

const onFinish = (values) => {
       const file = document.getElementById('inputFile').files[0];
       console.log(file) // consoles all file details before calling method
             Meteor.call('png.upload', {
                   lastModified: file.lastModified,
                   size: file.size
              }, (error, result) => {
                     if(error){
                          //console error
                       }
             }
}


You might want to take a look at this discussion. It’s a little out of date but worth reading. Upload files as form-data over DDP · Discussion #11523 · meteor/meteor · GitHub