class
ActiveStorage::Service::S3Service
- ActiveStorage::Service::S3Service
- ActiveStorage::Service
- Reference
- Object
Direct Known Subclasses
- ActiveStorage::Blob::RepresentableTest::StoredKeysService
- MartenRailsBridge::ActiveStorage::Representations::StoredKeysService
Defined in:
active_storage/service/s3_service.crConstructors
Instance Method Summary
-
#delete(key : String) : Nil
Removes the object stored under the passed key.
-
#delete_prefixed(prefix : String) : Nil
Removes every object whose key starts with the passed prefix.
-
#download(key : String) : String
Returns the whole content of the object stored at
key. -
#download(key : String, & : Bytes -> ) : Nil
Yields the content of the object stored at
key,CHUNK_SIZEbytes at a time. -
#download_chunk(key : String, range : Range(Int64, Int64)) : String
Returns the content of the object stored at
keyfor the passed inclusive byterange. -
#exist?(key : String) : Bool
Returns
truewhen an object is stored atkey. -
#private_url(key : String, expires_in : Time::Span, filename : ActiveStorage::Filename, disposition : String, content_type : String)
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
- #public_url(key : String, filename : ActiveStorage::Filename, content_type : String, disposition : String)
-
#upload(key : String, io : IO, checksum : String | Nil = nil, filename : ActiveStorage::Filename | Nil = nil, content_type : String | Nil = nil, disposition : String | Nil = nil) : Nil
Stores the content of the passed IO under the passed key.
Instance methods inherited from class ActiveStorage::Service
content_disposition_with(filename : Filename, type : String | Nil = "inline") : String
content_disposition_with,
delete(key : String) : Nil
delete,
delete_prefixed(prefix : String) : Nil
delete_prefixed,
download(key : String) : Stringdownload(key : String, & : Bytes -> ) : Nil download, download_chunk(key : String, range : Range(Int64, Int64)) : String download_chunk, exist?(key : String) : Bool exist?, private_url(key : String, expires_in : Time::Span, filename : Filename, disposition : String, content_type : String) private_url, public? : Bool public?, public_url(key : String, filename : Filename, content_type : String, disposition : String) public_url, upload(key : String, io : IO, checksum : String | Nil = nil, filename : Filename | Nil = nil, content_type : String | Nil = nil, disposition : String | Nil = nil) : Nil upload, url(key : String, expires_in : Time::Span, filename : Filename, content_type : String, disposition : String) url
Constructor methods inherited from class ActiveStorage::Service
new
new
Constructor Detail
Instance Method Detail
Removes the object stored under the passed key.
S3 answers 204 for a key nothing is stored under, so this does not raise on a missing object.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Removes every object whose key starts with the passed prefix.
One request per object: awscr-s3 exposes no batch delete, where Rails sends a page of keys at
a time through batch_delete!. A prefix with many objects is that many round trips.
A bucket that is not there holds no object, so it is not an error either, matching #delete.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Returns the whole content of the object stored at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Yields the content of the object stored at key, CHUNK_SIZE bytes at a time.
Like Rails, the object size is read first so that a missing object is reported before any chunk is yielded. https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Returns the content of the object stored at key for the passed inclusive byte range.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Returns true when an object is stored at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb
Stores the content of the passed IO under the passed key.
The content is sent in a single PUT: Rails switches to a multipart upload above
multipart_upload_threshold, this does not.
Content-MD5 carries the checksum so S3 rejects a corrupted body, and the serving headers are
stored next to the object the way Rails stores them.
An IO::Memory or a File is sent as it is, so the body never costs its own size in memory.
Both have to be at their start: awscr-s3 takes Content-Length from #size, which is the
whole object and not what is left to read. Any other IO is read into memory, because awscr-s3
needs a body that answers #size and that its signer can rewind after digesting it. A streamed
body is spent once it is written, so the retry the pinned awscr-s3 makes after a failed write
rewinds it first, and raises when it cannot.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/s3_service.rb