How to access server side clip attachments?

I use paperclip to attach excel file to mode.

The goal is to import data from an excel file into a database.

Model: Import
has_attached_file: spreadsheet

For the import process, I want to access the file in my model as follows.

path = "#{Rails.root}/public/#{spreadsheet.url}"    

This does not work. I think because in the end the url has a timestamp.

In general, what is the best way to access server-side attachments?

+3
source share
2 answers

I think you are looking for a method to_file. You should do something like this:

excel_file = self.spreadsheet.to_file

( s3, ), , ( model.save ), , .

.

spreadsheet.url(nil, false) - , .

+5

Source: https://habr.com/ru/post/1786739/


All Articles