Denis Worker
Denis Worker

Reputation: 39

Heroku file uploading and node.js

I tried upload file to Heroku using https://www.npmjs.com/package/express-fileupload, on my PC it works great, but on Heroku there are this error:

{"errno":-2,"code":"ENOENT","syscall":"open","path":"./public/owner_photo/f28397baea8fb4d6f6dafed9f5586a9ac0b46843acf1120a0ecad24755cfff57.jpeg"}

How can I fix it?

Upvotes: 1

Views: 3239

Answers (1)

Nathan Loyer
Nathan Loyer

Reputation: 1349

Heroku has an immutable file system, meaning you can't make changes to, or additions to the file system. You'll need to store your uploads somewhere else, like Amazon S3.

Also, many upload packages by default store the uploaded file in a temp directory. So even if you are sending them to S3, you'll still need to make sure the methods you use don't attempt to do that, or set an option to disable it. I'm not familiar with express-fileupload so I can't say what methods do or do not attempt to store copies on the filesystem.

I have successfully implemented this using multiparty so I could be of more specific help with that package.

Upvotes: 3

Related Questions