In my nestjs app deployed on DO app platform, I am uploading images and saving them in a directory tmp/folder/folder
The problem is when I GET the image and pass it into image tag’s src attributes it doesn’t work
<img src="tmp/folder/folder/30eb2c5251413f9ec49457bcab827db3" alt=""> this doesn't display the image
I don’t know what I am doing wrong here
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
If you are writing files for temporary use, you can use the local filesystem. However, keep these two things in mind:
Instances are ephemeral, and are being continuously created and destroyed as the app is scaled, redeployed, etc, and any changes to the filesystem will be destroyed with the instance. This means that every redeployment of your app will reset the filesystem.
If you have a multi-instance app from scaling horizontally, you should remember that each instance has a separate filesystem. Because of this, you should not use the local filesystem for anything that needs to be stateful.
More about that here:
In our case, I’ll recommend using Spaces. DigitalOcean offers a product called Spaces, which is compatible with Amazon’s S3 buckets. Spaces provide programmatic access to file storage at scale.
The App Platform storage is ephemeral, this means that after every new deployment, all of the data saved on there will be wiped out.
In order to store your data persistently, you should use S3 storage like the DigitalOcean Spaces:
That way your files will be uploaded to the S3 storage rather than the local storage of the App Platform.
Hope that this helps!