aws-S3 Rails reading a image file in binary format - ruby-on-rails

I'm currently working on an project which has implementation of an external api, and this api requires the image in binary format. The images are stored on s3, my question is how do read a file in binary format directly from the s3 without using a temp folder on the local end, so that I can pass it as a body of the request, for accessing the image i'm using
(s3client.buckets[ENV["AWS_S3_BUCKET"]].objects[params[:url].split("amazonaws.com/")[1]].read)
Can anyone help me out.
Thanks In Advance.

Related

MultipartUpload upload on S3 with AWS ios SDK

I want to upload large files on S3. I know there is an option multipart upload by which I can upload large file in parts. I read the documentation (http://docs.aws.amazon.com/mobile/sdkforios/developerguide/s3transfermanager.html) but didn't find any code for the multipart upload. I have successfully uploaded a file on server as a single file but I want to use multipart for large file.
Thanks.
IF you're still looking for a solution, you can check out my blog post on this subject: Taming the AWS framework to upload a large file to S3. For large files you will have to skip using the AWSTransferManager as it uses cognito credentials which are limited to an hour validity.

Using RackSpace cloudfiles with Paperclip gem

I've successfully uploaded, via Paperclip, images to the RackSpace cloudfile storage, and they appear correctly within subsequent webpages when I'm using the CDN url.
However, I can't figure out why Paperclip is not showing the files if I do not use CDN enabled cloud files.
Paperclip returns (via its 'url' method for the attachment) the more usual /attachments/fred/1/image/123.jpg path, however that results in a broken image as there is no actual file stored at that url - its in RS cloud file storage.
I'm not sure whether
a) Paperclip is supposed to give me a url to non-cdn location
b) Paperclip provides a url which results in it then responding at that url to provide the raw image data
c) Something completely different to a) and b)
If someone could please shed some light on what url I'm supposed to get back from Paperclip for non CDN enabled RackSpace stored files I think it would help steer me in the correct direction.
Thanks.
Rackspace Cloud Files has the ability to download files without a CDN, but after researching it paperclip and fog do not currently support this.
Paperclip supports both CDN access as well as downloading files using a temporary url (sans CDN). I was going to suggest using a temporary url, however, the get_http_url method paperclip uses to retrieve this url isn't currently implemented for Rackspace.
I have created a fog issue to address this https://github.com/fog/fog/issues/2103.

Configuring Multiple store directories - Carrierwave s3 upload

I have application where we have posts to which we upload photos. I have implemented S3 uploading module using carrier-wave and fog integration which is successful. But when images are uploaded along with versions the original file also getting stored in the same directory.
Is there any way to configure a separate folder inside my bucket to store only original images and rest of the images separately.
I also searched and learned that operating with multiple buckets is not yet possible with carrier-wave.
Kindly please direct me on this. Thanks in advance.

Extract metadata without uploading

I hava a Ruby on Rails application that works with video playlists. Now I would like to extract timecode information from the video file without uploading it to the server (takes to long). Is the possible?
If it is not possible, is there a way to export te metadata locally and uploads these xmls (for example) to the server?
Thanks in advance
afaik, this is not possible in browsers that do not support File API. Take a look at jquery file upload and the way it allows user to identify the file extension before upload.

paperclip upload a file to S3 from remote_url and token needed

I'm writing an importation function from a remote service to our app which uses S3. I connect to an api using OAuth as authentication, so every request I make I need to attach the token in the header. The attachments must be copied to S3 and the model is using paperclip.
I read the file from the api (say origin) with a GET method which returns a response with the body filled in with the content and the header with filename and other information.
Q: Now that I have the body of the file in plain text, how do I store it in S3 (destination) with paperclip?
Alternatively
Q: I could upload the file to S3 (destination) using remote URL(as described here), but how do I attach the token to the paperclip request to the (origin) api?
thanks
You need to create an s3.yml in your config directory... Here's a detailed tutorial in setting up paper clip with rails 3: http://doganberktas.com/2010/09/14/amazon-s3-and-paperclip-rails-3/
I would suggest you use a conversion tool to generate either a PDF or an editable document, then upload that to s3... Here's a good PDF gem: http://ruby-pdf.rubyforge.org/pdf-writer/ and even a railscast to help: http://railscasts.com/episodes/78-generating-pdf-documents
and here's an rtf gem: https://rubygems.org/gems/rtf
Since you have the raw data that should work.

Resources