class method
self.create_and_upload!
Ruby on Rails 6.0.6
Since v6.0.6Signature
self.create_and_upload!(io:, filename:, content_type: nil, metadata: nil, identify: true, record: nil)
Creates a new blob instance and then uploads the contents of the given io to the service. The blob instance is saved before the upload begins to avoid clobbering another due to key collisions.
When providing a content type, pass identify: false to bypass automatic content type inference.
Parameters
-
iokeyreq -
filenamekeyreq -
content_typekey = nil -
metadatakey = nil -
identifykey = true -
recordkey = nil
Source
# File activestorage/app/models/active_storage/blob.rb, line 76
def create_and_upload!(io:, filename:, content_type: nil, metadata: nil, identify: true, record: nil)
create_after_unfurling!(io: io, filename: filename, content_type: content_type, metadata: metadata, identify: identify).tap do |blob|
blob.upload_without_unfurling(io)
end
end
Defined in activestorage/app/models/active_storage/blob.rb line 76
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveStorage::Blob