https://github.com/benignware/base64_attachment
Upload base64-encoded file attachments to a rails rest service
https://github.com/benignware/base64_attachment
Last synced: 11 months ago
JSON representation
Upload base64-encoded file attachments to a rails rest service
- Host: GitHub
- URL: https://github.com/benignware/base64_attachment
- Owner: benignware
- License: gpl-2.0
- Created: 2014-09-11T16:56:57.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-26T12:02:47.000Z (over 11 years ago)
- Last Synced: 2025-07-27T11:18:06.650Z (11 months ago)
- Language: Ruby
- Homepage:
- Size: 195 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
base64_attachment
=================
> Upload base64-encoded file attachments to a rails rest service
This gem allows you to define `file`-attributes on an active record class which can receive base64-encoded strings which comes in handy for json rest clients posting images to a rails application.
Simply post your base64-encoded string using the `_base64`-suffix on the attribute name.
Usage
-----
Register your model for the base64-hook
```ruby
class Post < ActiveRecord::Base
has_attached_base64 :image
end
```
Post json
```json
{
"post": {
"image_base64": "base64-encoded string"
}
}
```
The content-type as well as the original_filename is automatically generated based on magic numbers using the [mime-magic](https://github.com/minad/mimemagic)-gem.