test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
The issue: I upload a file, it is being saved. I can access it, everything is ok. After a few minutes - I guess when the machine restarts - it is no longer accessible, I have this kind of error in the logs:
Errno::ENOENT (No such file or directory @ rb_sysopen - /rails/storage/d1/iy/d1iypphokiffgs0y9o7htur3kvgv)
I reupload the file, wait for ~5 minutes, and get again the same kind of error
Errno::ENOENT (No such file or directory @ rb_sysopen - /rails/storage/8k/lo/8klo4d4o05w1bpj2n7ynkevtz79f):
I tried modifying both fly.toml and storage.yml files (thinking the volume had to be mounted on /data mandatory for instance, but nothing seems to work).
So the questions are:
• What am I doing wrong?
• Are the files stored just temporary or longer term?
• What’s the best ay to make sure to access the files?
To answer your question, what you really want here is:
root: "/storage"
This needs to match destination in the [mounts] section of your fly.toml.
In general, a better option is Tigris S3. If you are interested, the process is basically fly storage create and what you would put in your config/storage.yml would look like the following:
Before you keep shooting from the hips, try to understand what’s happening w/ the mount path of the destination. That will explain why it’s not working locally.
It is quite likely that you want your development and production to be handled differently. Local with Rails.root.join("tmp/storage") is a good choice for development. Change production to be something different, that could be :production, :storage, :volume, or (my suggestion) :tigris.
Now back in config/storage.yml, define a new section with a matching name. If you want S3 Trigris, go with what I suggested previously. If you want to place the data on a volume, the outermost name must match what you specified in config/environments/production.rb, and the root much match what you specified in your fly.toml.