How to specify destination in multer to upload images to remote server folder in node js?

1k views Asked by At
app.post('/photo',[ multer({ dest:'http://example.com/images/new/',limits: {files: 8,fields: 18}}

This is not working as I am on other server and trying to upload it to another server's folder.How do I change this ?

1

There are 1 answers

1
NikhilWanpal On BEST ANSWER

If I understand correctly, your user is uploading an image to a node server, from where you wish to move the file to a different server, which either is physically not the same as your node server or you do not have access to the file system where the server is.

dest: The destination directory for the uploaded files

It means your server should have direct file system access to that folder. What you can do is: treat this destination as a temporary folder, from where you can move the file to your required final location using other schemes. Other schemes, meaning depending on the available communication between your server, it can be an scp call, or if it is a cloud server, probably aws-s3 module, depends. But multer will not do it automatically for you.