mohit chavda
mohit chavda

Reputation: 41

Rails Paperclip Error after upgrading ruby from 2.3.1 to 3.0.1

Existing project is in ruby 2.3.1 and upgrading version to 3.0.1 (rails 6.1.4) with related gems.

Updated gem to "paperclip" to "kt-paperclip".

I am getting following error while upload a document. Error:
[paperclip] Trying to link /tmp/RackMultipart20210809-20058-nn1h6f.jpeg to /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-f12xva.jpeg [paperclip] Trying to link /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-f12xva.jpeg to /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-tr9ezt.jpeg [paperclip] Trying to link /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-f12xva.jpeg to /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-ddtnlx.jpeg [paperclip] Trying to link /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-f12xva.jpeg to /tmp/a87ff679a2f3e71d9181a67b7542122c20210809-20058-ux65dm.jpeg

Following is my existing settings:

has_attached_file :file_local,
                path: ":rails_root/public/system/:attachment/:id/:style/:basename.:extension",
                url:  "/system/:attachment/:id/:style/:basename.:extension" 

has_attached_file :file,
            processors: [:format_delegator],
            path: ":configured_path",
            whiny: false,
            styles: {rectangle: ["1280x640#", :jpg],
                     narrow: ["640x", :jpg],
                     large: ["1980x", :jpg],
                     square: ["480x480#", :jpg],
                     thumbnail: ["1920x1080#", :jpg],
                     encoded: {output: "html5",
                               processors: [:transcoder]}},             
            default_url: :set_default_url,
            storage: :s3,
            url: SETTINGS[:amazon][:s3_alias_url], 
            s3_host_name: SETTINGS[:amazon][:host_name],
            s3_host_alias: SETTINGS[:amazon][:cloudfront_host],
            s3_permissions: :private,
            s3_protocol: :https,
            s3_region: SETTINGS[:amazon][:region],
            s3_credentials: {
                bucket: SETTINGS[:amazon][:bucket]
            }

Any one knows, how to solve above issue? Which configuration i need to check to track the issue?

Upvotes: 1

Views: 451

Answers (1)

mohit chavda
mohit chavda

Reputation: 41

I don't think it's an error. paperclip io_adapters/abstract_adapter.rb file having function link_or_copy_file in that one log is there.

 def link_or_copy_file(src, dest)
  begin
    Paperclip.log("Trying to link #{src} to #{dest}")
    FileUtils.ln(src, dest, force: true) # overwrite existing
  rescue Errno::EXDEV, Errno::EPERM, Errno::ENOENT, Errno::EEXIST => e
    Paperclip.log(
      "Link failed with #{e.message}; copying link #{src} to #{dest}"
    )
    FileUtils.cp(src, dest)
  end

  @destination.close
  @destination.open.binmode
end

It's only log, file is uploading in local folder.

Upvotes: 1

Related Questions