Closed avosa closed 1 year ago
I managed to solve the problem! This guide was all I needed!
Apparently, after every upload, the file is closed(I was trying to have the same file uploaded and transformed into different versions and the first transformation was the only one that was successful. To make the second and third transformation, I had to open the file again as it get closed once the operation is complete.
Here's how I fixed it:
response_1 = Cloudinary::Uploader.upload(@video.thumbnail, :transformation => resized_images[:img_64][:transformation])
@video.update(img_64: response["secure_url"])
response_2 = Cloudinary::Uploader.upload(@video.thumbnail.open, :transformation => resized_images[:img_128][:transformation])
@video.update(img_128: response["secure_url"])
response_3 = Cloudinary::Uploader.upload(@video.thumbnail.open, :transformation => resized_images[:img_256][:transformation])
@video.update(img_256: response["secure_url"])
As you can see, I only needed to add .open
method to the second and third transformation.
Extra resources/guide can be found here
I hope this helps somebody!
Describe the bug in a sentence or two.
When upload images simultaneously i encounter IOError with the message Closed stream.
Sample code looks like below