An application running on the cloud (heroku) doesn't have a persistent local file system.
Getting Started on Heroku with Node.js says ...
Use a database or object storage instead of writing to your local filesystem
... and Using AWS S3 to Store Static Assets and File Uploads says how to configure S3 (i.e. create a bucket) -- but it doesn't say how to use it!
So if a Node.js application wants to use a bucket (to write and read data from fles), what API does it use?
- Can it use a file system API (e.g. the
fs
package) -- for example is the S3 bucket mounted (visible to software to the application in the Heroku "Dyno") as a file system drive, named e.g.\data
? - Or must the application use an Amazon-specific API, e.g. one of the Amazon S3 client library for Node.js which are mentioned in answers to this topic?
- Or use Amazon's S3 REST API?
I'd mostly like to know whether I can access it via the fs
package, i.e. whether it's mounted as a file system drive (with a name like /data
so that e.g. I might read and write /data/hello.txt
).
If it can be accessed as a drive, perhaps that's the simplest or most familiar API -- and the easiest to develop, e.g. because then the application can use the local file system (instead of S3) when it's running on a development machine, and just the same except use the /data
drive when deployed to the cloud.