{"id":16748022,"url":"https://github.com/y9v/carrierwave-base64","last_synced_at":"2025-04-06T09:05:59.521Z","repository":{"id":26429821,"uuid":"29880327","full_name":"y9v/carrierwave-base64","owner":"y9v","description":"Upload files encoded as base64 strings directly to carrierwave","archived":false,"fork":false,"pushed_at":"2024-08-20T19:00:24.000Z","size":263,"stargazers_count":267,"open_issues_count":1,"forks_count":81,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T03:09:55.169Z","etag":null,"topics":["api","carrierwave","file-uploads","ruby"],"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/y9v.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-26T20:35:03.000Z","updated_at":"2024-08-20T19:00:17.000Z","dependencies_parsed_at":"2024-08-21T00:47:27.075Z","dependency_job_id":null,"html_url":"https://github.com/y9v/carrierwave-base64","commit_stats":null,"previous_names":["lebedev-yury/carrierwave-base64"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9v%2Fcarrierwave-base64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9v%2Fcarrierwave-base64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9v%2Fcarrierwave-base64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9v%2Fcarrierwave-base64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/y9v","download_url":"https://codeload.github.com/y9v/carrierwave-base64/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457799,"owners_count":20941906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","carrierwave","file-uploads","ruby"],"created_at":"2024-10-13T02:11:33.788Z","updated_at":"2025-04-06T09:05:59.497Z","avatar_url":"https://github.com/y9v.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Carrierwave::Base64\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/y9v/carrierwave-base64/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/y9v/carrierwave-base64/tree/master)\n[![Gem Version](https://badge.fury.io/rb/carrierwave-base64.svg)](http://badge.fury.io/rb/carrierwave-base64)\n[![Code Climate](https://codeclimate.com/github/y9v/carrierwave-base64/badges/gpa.svg)](https://codeclimate.com/github/y9v/carrierwave-base64)\n\nUpload files encoded as base64 to carrierwave.\n\nThis small gem can be useful for API's that interact with mobile devices.\n\nThis gem requires Ruby 2.0 or higher.\n\n## Installation\n\nAdd the gem to your Gemfile:\n\n```ruby\ngem 'carrierwave-base64'\n```\n\nAlso add this if you need mongoid support:\n\n```ruby\ngem \"carrierwave-mongoid\"\n```\n\n## Usage\n\nMount the uploader to your model:\n\n```ruby\nmount_base64_uploader :image, ImageUploader\n```\n\nNow you can also upload files by passing an encoded base64 string to the attribute. This also works for normal file uploads from file fields inside an HTML form, so you can safely replace `mount_uploader` with `mount_base64_uploader` to support both file input and base64 encoded input\n\n## Upload file extension\n\nThe file extension for the uploaded base64 string is identified automatically using the [mime-types](https://github.com/mime-types/ruby-mime-types/) gem and `content_type` from the uploaded string.\n\nIf the required MIME type is not registered, you can add it, using [MIME::Types#add](http://www.rubydoc.info/gems/mime-types/MIME/Types#add-class_method):\n\n```ruby\nMIME::Types.add(\n  MIME::Type.new('application/icml').tap do |type|\n    type.add_extensions 'icml'\n  end\n)\n```\n\n## Setting the file name\n\nYou can set the `file_name` option to a lambda, that will return a filename without an extension, using the model instance:\n\n```ruby\nmount_base64_uploader :image, ImageUploader, file_name: -\u003e (u) { u.username }\n```\n\n**[DEPRECATED: Settings this option to a string is deprecated, if you still want to set the filename to a fixed string, wrap it in a Proc]** To set the file name for the uploaded files, use the `:file_name` option (without extention):\n\n```ruby\n# Deprecated way:\nmount_base64_uploader :image, ImageUploader, file_name: 'userpic'\n\n# New way\nmount_base64_uploader :image, ImageUploader, file_name: -\u003e { 'userpic' }\n```\n\n## Data format\n\nFile extention for the uploaded file is identified automatically based on the file contents. If it can't be identified automaticaly, it falls back to the content-type, specified in the data string.\n\n```\ndata:image/jpeg;base64,(base64 encoded data)\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/carrierwave-base64/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy9v%2Fcarrierwave-base64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy9v%2Fcarrierwave-base64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy9v%2Fcarrierwave-base64/lists"}