dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

Dragonfly Attachment path is inconsistent

Open lcowell opened this issue 10 years ago • 1 comments

For some reason even though the path reported is different in the object that was responsible for creating the df resource and any other instance of the same record.

i = Image.create(:photo => File.new("spec/fixtures/sample.pdf"))
i.photo.path
# "/path/to/folder/spec/fixtures/sample.pdf"

i.reload.path
# "/path/to/folder/spec/fixtures/sample.pdf"

Image.find(i.id).photo.path
# "/path/to/folder/public/system/dragonfly/test/2015/10/06/21ye1ynb2h_sample.pdf"

lcowell avatar Oct 06 '15 21:10 lcowell

I just wanted to ping in on this. In my case after creating an object with an attachment the .path method points at the tmpfile still. If re-find the object it now has the .path pointing to the files final location on disk as it should.

In my use case, I'm creating the object, saving it, then attempting to send its file back to the user via Rails. Send_file breaks and sends a 0 length file because presumably the temporary file is deleted by the time Rails gets to send it.

Is this a bug? Should .path be updated with the final file location once the save has completed?

brendon avatar May 21 '18 01:05 brendon