lundi 21 septembre 2015

Read PDF from web and store it in S3 bucket

I am doing a project using ruby on rails which requires reading a pdf from web(link provided by users) and store in amazon S3 bucket.

Rails version 3.2

Ruby version 2.1.5

My sample code

require 'open-uri'
data = open('http://ift.tt/1WdJubN')

path = "pdf_files/123/sample.pdf"
AwsWrapper::S3Object.store(path, data, S3_CONFIG[:bucket], :content_type => 'pdf')

Above code stores that file in S3 but while opening the file I can't see data. It showing error message like Failed to load PDF document I am new to RoR. Please help me. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire