How to store image in node backend?

后端 未结 3 807
终归单人心
终归单人心 2021-01-16 06:08

I am using node and express for backend and Mongo DB for storage.I am using multer middleware for storing image,i got a problem and the problem is when i store an image from

3条回答
  •  春和景丽
    2021-01-16 06:35

    The filesystem on Heroku is not suitable for the persistent storage of data. The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy You can't store files on Heroku. Heroku automatically removed your uploaded files. You have to use external services like Amazon S3 or Azure Blob Storage.

    https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-node-examples.html https://docs.microsoft.com/en-us/javascript/api/@azure/storage-blob/blockblobclient?view=azure-node-latest

    If you don't want to set up an account with AWS to create an S3 bucket we also have add-ons here that handle storage and processing of static assets https://elements.heroku.com/addons

提交回复
热议问题