Where are my assets files stored? - heroku

As I have read, Heroku recommends pointing your CDN directly at your dynos rather than using asset_sync, therefore I did this:
# config/environments/production.rb
config.action_controller.asset_host = "<MY DISTRIBUTION SUBDOMAIN>.cloudfront.net"
The origin of my distribution is dcaclab.com
The CNAMEs of my distribution is assets.dcaclab.com
So, after I successfully pushed my rails 4 app to heroku, I found that all my assets are served from my cloudfront's distribution, like:
http://<MY DISTRIBUTION SUBDOMAIN>.cloudfront.net/assets/features/Multiple%20Circuits-edbfca60b3a74e6e57943dc72745a98c.jpg
What I don't understand, is how my assets files got uploaded to the my cloudfront's distribution?! also, where I can find them?
I thought they would be uploaded to my s3 bucket assets but it was just empty.
Can some enlighten me please?

If your files are being served from your CloudFront distribution and they are not being pulled from your S3 bucket "assets" as you previously thought, then you probably have set up your CloudFront distribution to use a custom origin such as your web server (S3 buckets are the normal/standard origins).
If you have set up your CloudFront distribution to use your web server as the origin, then CloudFront will pull the files from your web server before caching them on different edge locations (the pulling and caching is automatically done by CloudFront when a user access resources through the "distributionname.cloudfront.net" domain).
By the way, just a side note, I ran "dig assets.dcaclab.com" which resolves to "assets.dcaclab.com.s3.amazonaws.com".

If I read the intro docs correctly; you don't necessarily see them on Cloudfront, at least not outside of the management console. They're cached on edge nodes, and requested from your Origin if they're not found or expired. They're "uploaded" on-demand; the edge requests the file from the origin if it doesn't have it.

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.

How can I set cache-control on firebase console ? [SPEED UP Firebase Storage]

I was previously on S3 buckets but recently decided to go for firebase because I use other of their services.
Choice was firebase hosting or firebase storage.
- Hosting seems faster but, needs a full deploy at each update
- Storage allow me to upload only one file to the bucket if needed but is slower
Here's my issue : I added all my files in /images/ of the default bucket.
I can't find on the firebase console where to set cache-control.
How can I acheive that ? How can I gain more speed on firebase storage ?
Is there a default CDN on firebase Cloud Storage or can it be used with a CDN to have better speed an caching ?
PS: All my files are publicly readable as they are just images
PS 2: I can set cache-control when my users upload images throught my app, my question concerns images imported from the console interface

serving files from s3

I need to take the advantage of caching files at s3, I decided to put mu swf files at amazon bucket, but i get forbidden error at log of chrome
How can I have a swf file hosted at heroku to load swf file hosted at amazon bucket?
If I understand things correctly you might have an issue with crossdomain loading (crossdomain.xml). Please see this link for an elaborate answer on how to solve it: Writing Flash crossdomain.xml for Amazon 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.

How to upload images on heroku server using attachment_fu plugin

I have an app in Heroku, I need simple file storage for uploaded images for this I
used send_data using attachment_fu plugin.
After that I have used the tmp/ directory to write this file and want to display on browser, But these files are not displayed in browser.
How can I display these images on browser?
What is the alternate solution to store and retrieve images?
Thanks!
You cannot store uploaded files on Heroku.
You must use an alternative strategy. A couple alternative strategies:
Store uploaded files in your database on Heroku. Because database systems are not specifically optimized for storing files, you should test out how well your application performs under load before you use this strategy.
Store uploaded files in an external storage service. Amazon S3 is a popular cloud storage service that anyone can use, and it has pay-as-you-go pricing just like Heroku. (In fact, Heroku itself runs on top of another of Amazon's cloud services, EC2.)

Resources