Empty file uploaded from tempfile

We’re trying to reuse some files that are already stored via other records. We thought we could use <model>.<UploadedFile>.download to get a tmpfile we could then upload and store, but we’re seeing empty files being created. The issue we’re seeing is that the tempfile created is valid on disk, but when passing it through Shrine.upload we’re getting an empty file stored in the new location.

Any insight would be greatly appreciated.

Here is a very small example:

[173] pry(main)> temp = artwork.image.download
=> #<File:/tmp/shrine20211006-229-fnfzsr.tif>

[174] pry(main)> puts `ls -lh #{temp.path}`
-rw------- 1 docker docker 593K Oct  6 19:25 /tmp/shrine20211006-229-fnfzsr.tif

[175] pry(main)> upload = Shrine.upload(temp, :cache)
=> #<Shrine::UploadedFile storage=:cache id="bbb9e6d67ef9287e70a1cf53911aeb2a.tif" metadata={"filename"=>"shrine20211006-229-fnfzsr.tif", "size"=>607176, "mime_type"=>nil}>

[176] pry(main)> puts `ls -l /mnt/storage/cache/#{upload.id}`
-rw-r--r-- 1 docker docker 0 Oct  6 19:25 /mnt/storage/cache/bbb9e6d67ef9287e70a1cf53911aeb2a.tif

Turns out this is related to docker volumes - https://github.com/docker/for-linux/issues/1015

1 Like