You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class SomeModel < ActiveRecord::Base
has_attachment :image, accept: [:png]
validates :name, presence: true # where name is an unrelated field to the image attachment
end
and a statement
sm = SomeModel.new(image: File.open('/path/to/file.png'));
my tests indicate that the image given will be uploaded to Cloudinary even though the model itself can't be created due to a failed validation. This appears to be true because upload happens during the initialize assignment of values to model attributes.
I was able to work around it in my model to defer the upload until after_create, but I'd prefer not to. The other alternative I suppose is to rollback the upload (i.e., remove from Cloudinary) on a failed create.
The text was updated successfully, but these errors were encountered:
yes. that's true. I recognized the same behaviour. This leeds to massive unused resources on the cloudinary side exceeding the storage capacity quickly
When I build a new Object like Post.new(media_url: "http://example.com/your-image.jpg")
The file is uploaded directly: ok so far. But as I not saved the entity locally I assume the Attachinary::TMPTAG is added to the cloudinary-resource. But it is not. When I fetch the tagged resources I get an empty array: Cloudinary::Api.resources_by_tag(Attachinary::TMPTAG)
For instance, given the following model:
and a statement
my tests indicate that the image given will be uploaded to Cloudinary even though the model itself can't be created due to a failed validation. This appears to be true because upload happens during the initialize assignment of values to model attributes.
I was able to work around it in my model to defer the upload until after_create, but I'd prefer not to. The other alternative I suppose is to rollback the upload (i.e., remove from Cloudinary) on a failed create.
The text was updated successfully, but these errors were encountered: