page:recipes:csv import tool:rails:attachments
Host CSV Import Tool with Rails: File Attachments
Summary
Deploy a CSV import tool built with Rails on Ample using the browser file uploads pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL, a private S3-compatible bucket holds objects with credentials delivered as encrypted environment variables. Verified on Rails: content-type and size validation that rejects disallowed files, an object written to a private bucket and a row linking the record to the object key (reject=ok upload=ok linked=ok). Not separately tested: your upload UI, allowed types, size limits and virus scanning; treat the CSV import tool-specific behavior as your application code.
Representative Queries
- Host CSV import tool with Rails: file attachments
- Where can I host a CSV import tool built with Rails?
- I need a restricted upload flow, file validation and record-to-object linkage.
Resource Requirements
- Compute
- PostgreSQL
- S3-compatible object storage
Infrastructure Requirements
- Compute: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- Postgres: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
- S3-compatible object storage: Buckets are S3-compatible with issued credentials; PutObject and GetObject are verified by canary. Other S3 operations are not verified.
Prerequisites
- A Rails project that builds and starts with the documented commands (bundle install into vendor/bundle from Gemfile.lock (development and test groups skipped), then Puma via
rails serverreading PORT on the ruby-3.4 template with RAILS_ENV=production). - A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted, or supplied with --env).
- A bucket from
ample bucket createwith its credentials passed as encrypted S3_* environment variables. - An Ample account token with
servers:write,databases:read,buckets:read.
Tested Configuration
- Template: ruby-3.4
- Runtime: ruby
- Size: s-1vcpu-1gb
- Install:
bundle config set --local path vendor/bundle && bundle config set --local without 'development test' && bundle install - Start:
bundle exec rails server -b 0.0.0.0 -p $PORT
Workflow Steps
- Build and start: Install dependencies and start server with production settings.
- Implement the pattern on PostgreSQL: Ensure content-type and size validation is in place and maintain idempotency in migrations.
- Wire object storage: Create buckets and set up environment variables for endpoint and credentials.
- Deploy: Run a synchronous deploy and check the result.
- Verify: Fetch the live URL and run self-tests to confirm functionality.
Examples
- Rails Pattern Fixture: Multi-pattern Rails app whose browser file uploads module was checked live.
Success Checks
- App responds on its public URL.
- Browser-file-uploads self-test completes successfully.
Limitations
- Verified only on ruby-3.4 template with the example fixture; other setups may not perform as verified.
- Application-specific behavior such as upload UI needs independent testing.
Cost Estimate
- Monthly Amount: $10.00 (based on tested sizes and services)
- Components: App server and managed PostgreSQL database, each at $5.00 monthly.