abstract class
ActiveStorage::Service
- ActiveStorage::Service
- Reference
- Object
Direct Known Subclasses
Defined in:
active_storage/service.crConstant Summary
-
CHUNK_SIZE =
(5 * 1024) * 1024 -
Amount of bytes a service yields per chunk when a file is downloaded in a streamed way.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service/disk_service.rb
Constructors
Instance Method Summary
-
#content_disposition_with(filename : Filename, type : String | Nil = "inline") : String
Returns the
Content-Dispositionvalue to serve the passed filename with. -
#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 file stored at
key. -
#download(key : String, & : Bytes -> ) : Nil
Yields the content of the file stored at
key,CHUNK_SIZEbytes at a time. -
#download_chunk(key : String, range : Range(Int64, Int64)) : String
Returns the content of the file stored at
keyfor the passed inclusive byterange. -
#exist?(key : String) : Bool
Returns
truewhen a file exists atkey. - #private_url(key : String, expires_in : Time::Span, filename : Filename, disposition : String, content_type : String)
- #public? : Bool
- #public_url(key : String, filename : Filename, content_type : String, disposition : String)
-
#upload(key : String, io : IO, checksum : String | Nil = nil, filename : Filename | Nil = nil, content_type : String | Nil = nil, disposition : String | Nil = nil) : Nil
Stores the content of the passed IO under the passed key.
- #url(key : String, expires_in : Time::Span, filename : Filename, content_type : String, disposition : String)
Constructor Detail
Instance Method Detail
Returns the Content-Disposition value to serve the passed filename with.
Any disposition other than attachment falls back to inline, matching Rails.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Removes the object stored under the passed key.
Deleting a key nothing is stored under is not an error, matching Rails.
Raises NotImplementedError unless the service implements it, as the Rails base service does.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Removes every object whose key starts with the passed prefix.
A prefix nothing is stored under is not an error, matching #delete.
Raises NotImplementedError unless the service implements it, as the Rails base service does.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Returns the whole content of the file stored at key.
Raises ActiveStorage::FileNotFoundError when no file is stored at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Yields the content of the file stored at key, CHUNK_SIZE bytes at a time.
Raises ActiveStorage::FileNotFoundError when no file is stored at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Returns the content of the file stored at key for the passed inclusive byte range.
Raises ActiveStorage::FileNotFoundError when no file is stored at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Returns true when a file exists at key.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb
Stores the content of the passed IO under the passed key.
When a checksum is given it is the base64 MD5 of the content, and the upload fails with
ActiveStorage::IntegrityError when the stored content does not match it.
filename, content_type and disposition are the ones the content must be served with:
they are stored next to the object by the services that support it.
Raises NotImplementedError unless the service implements it, as the Rails base service does.
https://github.com/rails/rails/blob/v8.1.3/activestorage/lib/active_storage/service.rb