{"id":34733970,"url":"https://github.com/startae/uploadbox","last_synced_at":"2026-04-08T13:31:10.036Z","repository":{"id":59158730,"uuid":"10539959","full_name":"startae/uploadbox","owner":"startae","description":"Easy uploads for Rails application","archived":false,"fork":false,"pushed_at":"2016-10-11T17:30:13.000Z","size":1088,"stargazers_count":11,"open_issues_count":5,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-12-26T14:04:45.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/startae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-07T01:18:37.000Z","updated_at":"2022-07-13T00:30:25.000Z","dependencies_parsed_at":"2022-09-13T17:50:51.305Z","dependency_job_id":null,"html_url":"https://github.com/startae/uploadbox","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/startae/uploadbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startae%2Fuploadbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startae%2Fuploadbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startae%2Fuploadbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startae%2Fuploadbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/startae","download_url":"https://codeload.github.com/startae/uploadbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startae%2Fuploadbox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31558379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-25T03:22:09.671Z","updated_at":"2026-04-08T13:31:10.027Z","avatar_url":"https://github.com/startae.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Uploadbox\n\nEasy uploads for Rails application\n\n[![Code Climate](https://codeclimate.com/github/startae/uploadbox.png)](https://codeclimate.com/github/startae/uploadbox)\n\n## Early Beta\n\nThis is still an early beta version and will change a lot until it reaches API stability.\nThat said, it's already being used on production projects.\n\n\n## Installation\n\nMake sure you have [ImageMagick](http://www.imagemagick.org/) installed.\n\n#### Add to Gemfile\n\n```\ngem 'uploadbox', '0.2.0'\n```\n\n#### Run generators\n\n```\nrails g uploadbox:image\n```\n\n#### Migrate database\n\n```\nrake db:migrate\n```\n\n#### Add jquery and uploadbox to `application.js`\n\n```\n//= require jquery\n//= require jquery_ujs\n//= require uploadbox\n```\n\n#### Add uploadbox to `application.css`\n\n```\n/*\n *= require uploadbox\n */\n```\n\n#### Create a development bucket on [Amazon S3](http://aws.amazon.com/s3/)\n\n#### Edit CORS config for the bucket\n\n```\n\u003cCORSConfiguration\u003e\n  \u003cCORSRule\u003e\n    \u003cAllowedOrigin\u003ehttp://localhost:3000\u003c/AllowedOrigin\u003e\n    \u003cAllowedMethod\u003eGET\u003c/AllowedMethod\u003e\n    \u003cAllowedMethod\u003ePOST\u003c/AllowedMethod\u003e\n    \u003cAllowedMethod\u003ePUT\u003c/AllowedMethod\u003e\n    \u003cAllowedHeader\u003e*\u003c/AllowedHeader\u003e\n  \u003c/CORSRule\u003e\n\u003c/CORSConfiguration\u003e\n```\n\n#### Get S3 Key and Secret from Amazon S3 Credentials and update your `secrets.yml` file.\n\n```\ndevelopment:\n  s3_bucket: your-bucket-name\n  s3_key: your-s3-key\n  s3_secret: your-s3-secret\n```\n\n## Usage\n\n### uploads_one\n\n#### Add `uploads_one` to your model\n\n```\nclass Post \u003c ActiveRecord::Base\n  uploads_one :picture, thumb: [100, 100], regular: [600, 300], placeholder: 'default.png'\nend\n```\n\nIf `placeholder` is set posts without uploads will render the placeholder.\nEmpty `@post.picture.thumb` will render `app/assets/images/thumb_default.png`\n\n#### Add field to form\n\n```\n\u003c%= f.uploads_one :picture %\u003e\n```\n\nYou can pass a `:preview` option, so that the field will have the dimensions specified in the model.\n\n```\n\u003c%= f.uploads_one :picture, preview: :thumb %\u003e\n```\n\n\n#### Allow attribute on controller\n\n```\ndef post_params\n  params.require(:post).permit(:title, :body, :picture)\nend\n```\n\n#### Show image\n\n```\n\u003c%= img @post.picture.regular if @post.picture? %\u003e\n```\n\n### uploads_many\n\n#### Add `uploads_many` to your model\n\n```\nclass User \u003c ActiveRecord::Base\n  uploads_many :pictures, thumb: [100, 100], regular: [600, 600], placeholder: 'default.png'\nend\n```\n\n#### Add field to form\n\n```\n\u003c%= f.uploads_many :pictures %\u003e\n```\n\nYou can pass a `:preview` option, so that the field will have the dimensions specified in the model.\n\n```\n\u003c%= f.uploads_one :pictures, preview: :thumb %\u003e\n```\n\n#### Allow attributes on controller\n\n```\ndef post_params\n  params.require(:user).permit(..., pictures: [])\nend\n```\n\n#### Show images\n\n```\n\u003c% @user.pictures.each do |pic| %\u003e\n  \u003c%= img pic.regular %\u003e\n\u003c% end %\u003e\n```\n\n#### Set `background_processing` to `false` if you're using Heroku\n\nGo to `config/initializers/uploadbox.rb`, find the line where `background_processing` is being set and set it to `false`.\n\n```\nUploadbox.background_processing  = false\n```\n\n## Recreate versions\n\nYou might come to a situation where you want to retroactively change a version or add a new one. You can use the `update_#{upload_name}_versions!` method to recreate the versions from the base file.\nFor a post with a picture:\n\n```\nPost.update_picture_versions!\n```\n\n\n## Heroku\n\n#### Create a production bucket on S3 (Don't use your development bucket)\n\n```\n\u003cCORSConfiguration\u003e\n  \u003cCORSRule\u003e\n    \u003cAllowedOrigin\u003ehttp://yourdomain.com\u003c/AllowedOrigin\u003e\n    \u003cAllowedMethod\u003eGET\u003c/AllowedMethod\u003e\n    \u003cAllowedMethod\u003ePOST\u003c/AllowedMethod\u003e\n    \u003cAllowedMethod\u003ePUT\u003c/AllowedMethod\u003e\n    \u003cAllowedHeader\u003e*\u003c/AllowedHeader\u003e\n  \u003c/CORSRule\u003e\n\u003c/CORSConfiguration\u003e\n```\n\n#### Set environment variables\n\n```\nheroku config:add \\\nHEROKU_API_KEY=ab12acvc12 \\\nHEROKU_APP=your-app-name \\\nS3_KEY=AAAA123BBBB \\\nS3_SECRET=abc123ABcEffgee122 \\\nS3_BUCKET=uploads-production\n```\n\n#### Update your secrets.yml file\n\n```\nproduction:\n  s3_key:  \u003c%= ENV[\"S3_KEY\"] %\u003e\n  s3_secret: \u003c%= ENV[\"S3_SECRET\"] %\u003e\n  s3_bucket: \u003c%= ENV[\"S3_BUCKET\"] %\u003e\n```\n\n#### Add Redis\n\n```\nheroku addons:add rediscloud\n```\n\n## Upgrade from 0.1.x\n\nIf are upgrading from 0.1.x you will need to create a migration to add a column named `original_file` to the `images` table\n\n```\nrails g migration add_original_file_to_images original_file:string\nrake db:migrate\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartae%2Fuploadbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstartae%2Fuploadbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartae%2Fuploadbox/lists"}