Paperclip not Uploading to Bucket, No Error Returned

snowYetis

I have been battling this one for a while now. I have am using Paperclip and AWS-SDK. I have my bucket and account configured. Permissions are granted. The form data, including the Paperclip model values all save to my Sqlite3 table. However, the image does not upload to my bucket on S3. I receive no errors. Any suggestions on what could be going wrong here?

Thanks in advance.

Here's is the attachment control, which is inside my form. The form routes to the Create method on my Animal controller.

Development Config (I have verified I am in dev mode)

Paperclip.options[:command_path] = "/usr/local/bin/"

 config.paperclip_defaults = {
  :storage => :s3,
  :bucket => ENV["my bucket"],
  :s3_credentials => {
      :access_key_id => ENV["My ID"],
      :secret_access_key => ["My Secret"]
  }
}

  Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
  Paperclip::Attachment.default_options[:path] =    '/:class/:attachment/:id_partition/:style/:filename'

Animal/new.html.erb

   <div class="form-group padding-top-bottom-10">
      <%= f.file_field :animal_image %>
      <label class="label label-warning">Attach Your Photo</label>
      <div class="row padding-top-bottom-10"></div>
   </div>

Animal Controller

 def create

@animal = Animal.new(animal_params)
respond_to do |format|
    if @animal.save
      flash[:notice] = "#{@animal.full_name} has been added to your profile."
      format.json { render json: @animal, status: :created, location: @animal }
      format.html { render "animal/index" }
    else
      flash.now[:error] = @animal.errors.full_messages
      format.html { render action: "new" }
      format.json { render json: @animal.errors, status: :unprocessable_entity }
    end
  end
end

private
def animal_params

params.require(:animal).permit(:full_name, :profile_id, :age, :gender, :purr_factor,           :weight, :height,
                                            :length, :fixed, :shots, :papers, :animal_desc, :breed_id, :animal_image)
end

Animal.rb

        :animal_image_content_type
        :animal_image_file_name

        has_attached_file :animal_image, style: {
         thumb: '100x100>',
         square: '200x200#',
         medium: '300x300>'
        }

        # Validate the attached image is image/jpg, image/png, etc
       validates_attachment_content_type :animal_image, :content_type => /\Aimage\/.*\Z/
snowYetis

So I figured it out and I figured I should post the solution, so that way I can get more down votes. Even though I have seen countless Paperclip posts on here with similar problems, whom, received multiple up votes.

Removing the credentials from my config/environments/development file and placing all configuration in my model seemed to do the trick. Also, I had a hash symbol in my style field.

  has_attached_file :animal_image,
                    :style => {:medium => "300x300>", :thumb => "100x100>"},
                    :storage => :s3,
                    :bucket  => "my bucket",
                    :s3_credentials => {
                        :bucket  => "my bucket",
                        :access_key_id => ENV["My key"],
                        :secret_access_key => ENV["My Secret"]
                    },
                    :s3_permissions => "private",
                    :url => ":s3_domain_url"
                    Paperclip::Attachment.default_options[:url] = ":s3_domain_url"
                    Paperclip::Attachment.default_options[:path] = "/:class/:attachment/:id_partition/:style/:filename"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error when uploading large file with Paperclip and AWS

From Dev

Error uploading non image files with paperclip in rails 4.2

From Dev

error uploading video with paperclip-av-transcoder in rails 4

From Dev

paperclip file not uploading

From Dev

Uploading multiple images with paperclip?

From Dev

Error while uploading file to Amazon S3 bucket

From Dev

Amazon S3 bucket MalformedXML error when uploading

From Dev

Uploading an image with paperclip? Rails 4

From Dev

Rails - paperclip not uploading any images

From Dev

Rails Paperclip Gem File Not Uploading

From Dev

How to fix s3/paperclip/rails template error missing :bucket option?

From Dev

"Unknown attribute: avatar" when uploading image with Paperclip?

From Dev

Rails 4 Paperclip FactoryGirl file uploading

From Dev

Set Paperclip image field to url without uploading

From Dev

Uploading an image without a form or database in PaperClip

From Dev

Uploading a pdf to rails using paperclip not working

From Dev

Rails 4 Paperclip FactoryGirl file uploading

From Dev

Error uploading to a non-US Standard AWS S3 Bucket in Django application; US Standard bucket works perfectly

From Dev

Error uploading to a non-US Standard AWS S3 Bucket in Django application; US Standard bucket works perfectly

From Dev

heroku paperclip weird error Paperclip::Errors::MissingRequiredValidatorError

From Dev

Paperclip gem spoofing error?

From Dev

Ruby on Rails - Paperclip Error

From Dev

Paperclip error - NotIdentifiedByImageMagickError

From Dev

Paperclip and Dropbox Error

From Dev

PaperClip No handler found Error

From Dev

Paperclip error - NotIdentifiedByImageMagickError

From Dev

Paperclip: Permission denied error

From Dev

Paperclip validation error on rails

From Dev

PermanentRedirect error while uploading to S3 bucket with aws-sdk-java

Related Related

  1. 1

    Error when uploading large file with Paperclip and AWS

  2. 2

    Error uploading non image files with paperclip in rails 4.2

  3. 3

    error uploading video with paperclip-av-transcoder in rails 4

  4. 4

    paperclip file not uploading

  5. 5

    Uploading multiple images with paperclip?

  6. 6

    Error while uploading file to Amazon S3 bucket

  7. 7

    Amazon S3 bucket MalformedXML error when uploading

  8. 8

    Uploading an image with paperclip? Rails 4

  9. 9

    Rails - paperclip not uploading any images

  10. 10

    Rails Paperclip Gem File Not Uploading

  11. 11

    How to fix s3/paperclip/rails template error missing :bucket option?

  12. 12

    "Unknown attribute: avatar" when uploading image with Paperclip?

  13. 13

    Rails 4 Paperclip FactoryGirl file uploading

  14. 14

    Set Paperclip image field to url without uploading

  15. 15

    Uploading an image without a form or database in PaperClip

  16. 16

    Uploading a pdf to rails using paperclip not working

  17. 17

    Rails 4 Paperclip FactoryGirl file uploading

  18. 18

    Error uploading to a non-US Standard AWS S3 Bucket in Django application; US Standard bucket works perfectly

  19. 19

    Error uploading to a non-US Standard AWS S3 Bucket in Django application; US Standard bucket works perfectly

  20. 20

    heroku paperclip weird error Paperclip::Errors::MissingRequiredValidatorError

  21. 21

    Paperclip gem spoofing error?

  22. 22

    Ruby on Rails - Paperclip Error

  23. 23

    Paperclip error - NotIdentifiedByImageMagickError

  24. 24

    Paperclip and Dropbox Error

  25. 25

    PaperClip No handler found Error

  26. 26

    Paperclip error - NotIdentifiedByImageMagickError

  27. 27

    Paperclip: Permission denied error

  28. 28

    Paperclip validation error on rails

  29. 29

    PermanentRedirect error while uploading to S3 bucket with aws-sdk-java

HotTag

Archive