Strapi deployed to Heroku but media files give 404 error - strapi

I've deployed Strapi on Heroku and have set up the content fine. When I uploaded images and videos to Strapi using the cms interface and saved the update. it saved successfully but the file url returns 404. has anyone experienced this before? Am I missing something?
Thanks guys.

https://strapi.io/documentation/3.0.0-beta.x/guides/deployment.html#file-uploads
File Uploads
Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called ephemeral, which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day).
Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers here and you can see a list of providers from both Strapi and the community on npmjs.com.

Related

Directus images disappear after a while

I created a Next.js project that is deployed on Vercel and uses a MySQL database. I then deployed a Directus instance on Heroku that is tied to that same database. In my Next.js project I want to fetch and render images that I uploaded to Directus. At first this works, but after a while all the images disappear in the Directus media library. The folders and references to the images are still there, but I don't see the pictures anymore, I get to see a JPG logo instead. When I try to fetch the images I get a 502 "Bad Gateway" error. I don't know what causes the images to disappear and how to fix this.
By default, Directus stores uploaded files locally on disk.
All Heroku applications run in a collection of lightweight Linux containers called dynos. Be aware that Heroku dyno's filesystem is ephemeral.
It means if your Heroku app doesn't receive any traffic for 30 minutes or is being deployed, the VM it lives on is destroyed, and its filesystem goes along with it. So, this filesystem should not be used for any permanent storage (Directus storage in your case).
You can configure Directus to use S3, Google Cloud Storage, Azure, or Cloudinary.
For more details check the File Storage Directus docs.

heroku and nuxt file uploader not working

I have a PWA made with NuxtJS correctly deployed and working on Heroku.
I would like to implement a file uploader and manager so that I can manage some files in a directory (~/static/files) from my front-end through some APIs.
On localhost, it works fine so I have my directory and when I add or delete the file, it deletes or creates it from the file system (as it should).
My question is: why can't I do the same on Heroku? I mean, I tried by uploading a file and deleting it and it works but the problem comes when I restart the app (through heroku ps:restart -a appname) because when I do so it deletes the file as if it was saved in RAM and not onto the file system.
If I try to see the files in the directory where they should be through heroku run bash -a appname and then down to the directory, no file is showed.
How can I fix this?
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. This is similar to how many container based systems, such as Docker, operate.
In addition, under normal operations dynos will restart every day in a process known as "Cycling".
These two facts mean that the filesystem on Heroku is not suitable for persistent storage of data. In cases where you need to store data we recommend using a database addon such as Postgres (for data) or a dedicated file storage service such as AWS S3 (for static files).

Parse- Server Transferring files hosted on Heroku to AWS S3 bucket

I have parse-server running on Heroku. When I first created this app, I didn't specify a files adapter in index.js, so all uploaded files have been getting stored on Heroku.
So I have now run out of room and I have set up an AWS S3 bucket to store my files on. This is working fine expect for the fact that any files which were originally stored on Heroku can no longer be accessed through the application.
At the moment I am thinking about looping through all objects which have a relation to a file stored on heroku, then uploading that file to S3 bucket. Just hoping that there may be some tool out there or that someone has an easier process for doing this.
thanks
There are migration guides for migrating parse server itself but I don't see anything in the documentation for migrating hosted files unfortunately.
I did find one migration tool but it appears to still utilize the previous file adapter (on your heroku instance) and then stores anything new on the new adapter (s3 storage).
parse-server-migrating-adapter

Save images not properly display on heroku

i'm using Rails 3.2.6 and using carrierwave to upload images.When i upload image it is display fine and its image url also working well. But when i push next git commit on heroku.
git push staging master
than all images that i had already upload not display and its image path are not working
why?
Please anyone can tell what's the problem is running.
Thnaks
Whilst your uploads will work - the moment you push new code, or your application is restarted you will loose any uploads.
Heroku uses an Ephemeral file system, in that each dyno receives a separate copy (slug) of the originally deployed code so uploads would only exist on the dyno that handled the upload (https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem).
You need to use an external persistant data store like Amazon S3, Rackspace Files etc - fortunately with Carrierwave it's trivial to update it to use it as it supports it out of the box.
Did you setup carrierwave with s3 (https://github.com/jnicklas/carrierwave#using-amazon-s3)?
Heroku has a read only file system (https://devcenter.heroku.com/articles/s3).

how to migrate heroku file storage to S3

I am an idiot, and very new to Heroku. I used the heroku file system to store paperclip attached files to my models.
Have I lost these files? And can I unload them to S3 somehow and have better access?
Its a low traffic site but its causing problems as it should for me to have it setup to store locally on the server.
You can assume you've lost the files - if the app has been restarted/scaled/deployed to then they'll have gone.
You'll want to get it setup to save the files to S3 in the future.

Resources