7

का उपयोग कर अमेज़ॅन एस 3 पर सीधे सीधी अपलोड रेल मैं अपने रेल ऐप पर छवियों को अपलोड करने के लिए एक्टिवैडमिन और पेपरक्लिप का उपयोग कर रहा हूं। जब मैं S3 पर बड़ी फ़ाइलों को अपलोड करने का प्रयास करता हूं तो टाइमआउट त्रुटि होती है, इसलिए मुझे S3 पर सीधे अपलोड लागू करना होगा।एक्टिवैडिन + पेपरक्लिप

क्या कोई जानता है कि मैं इसे कैसे बना सकता हूं? मैं इसे समझ नहीं पाया ...

+0

http://blog.littleblimp.com/post/53942611764/direct-uploads-to-s3-with-rails-paperclip-and –

उत्तर

3

एक really nice article मैं जब गया था पहली बार AA+s3+Paperclip की स्थापना का उपयोग किया है नहीं है।

इसमें सभ्य स्पष्टीकरण + example app on Github है, ताकि आप इसे लाइव देख सकें।

ए.ए. में प्रपत्र कुछ इस तरह दिखेगा:

form multipart: true do |f| 
    # f.semantic_errors *f.object.errors.keys 
    f.inputs do 
    f.input :image_name #or whatever field is called 
    end 
    f.has_many :attachments do |a| 
     if a.object.persisted? 
     link_to image_tag(a.object.encoded_url, class: 'image-preview'), a.object.encoded_url, target: "_blank" 
     else 
     a.inputs do 
      a.s3_file_field(:attachment, as: :file, class: 'js-s3_file_field') 
     end + 
     a.inputs do 
      a.input(:s3_url, as: :hidden, input_html: { class: "s3_url" }) 
     end 
     end 
    end 
    f.actions 
end 
+0

मुझे नहीं पता क्यों, लेकिन मुझे रेगेक्स के साथ समस्याएं हैं जो प्रत्यक्ष यूआरएल को मान्य करती हैं, जो है: 'DIRECT_UPLOAD_URL_FORMAT =% r {\ Ahttps: \/\/s3 \ .amazonaws \ .com \/myapp # {! Rails.env.production? ? "\\ - # {Rails.env}": ''} \/(? अपलोड \ /.+ \/(? । +)) \ Z} .freeze' क्या आपको इसके साथ कोई समस्या है? –

+0

@ हेनरिक अमारल मैंने नहीं किया .. –