Closed abhas closed 11 years ago
@abhas Because the GridFS specification expects a file path (just like you need to have a file path to store a file on your local filesystem or S3), a path is eventually necessary.
However, this gem can store anything that's deemed "readable." If you give put
just a file path, it will try to open
it for reading. If you give it something that responds to read
, it will just do that. put
also takes :filename
option if you want to give it an explicit filename. Alternatively, you can use []=
to assign a readable object to a filename.
I'm using the
rmagick
gem to split a PDF into images and store the resulting images into GridFS. However, this gem requires me to pass a file path to store a file to GridFS. Is there a way I could pass a blob and store it as a file?In the earlier
mongoid_grid
gem, I could use aset_file
method to set the contents of a file that I was uploading. I wish I could do the same thing here without having to first write the file to a temporary file.Thanks a lot!