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
Fil.Adapter.Zip reads the files of a zip archive on any disk, read-only. It reads only the parts of the archive it
needs, with ranged reads, so a file in a large archive on S3 costs a few requests. It reads stored and deflated
entries and Zip64 archives, checks each whole entry against its CRC-32, never inflates an entry past its declared
size, and leaves out entries whose names escape the archive's root. Every change returns Fil.AccessDeniedError with reason: :read_only. (#48)
Fil.Adapter.AzureBlob stores files in Azure Blob Storage and Azurite, signed with the account key (Shared Key) or
sent with a SAS token. Streams without a size are uploaded in blocks and committed at the end, checksum: is stored
as blob metadata, and Fil.signed_url/3 and Fil.signed_upload/3 return service SAS URLs. A SAS can't bind the
content type, the size or extra query parameters, so query: returns a Fil.UnsupportedError, and Fil.LiveView
checks the content type and the size of a direct upload when it's consumed, and Fil.Plugin.Validation refuses to
sign an upload whose size or type its rules need. The Livebook smart cell builds Azure disks too.
(#42)
Fil.signed_upload/3 signs a direct upload and returns a map with the method, the URL, the headers and form fields
the client has to send, and when the URL expires. They come from the disk, so a client passes them on as they are, and Fil.LiveView's uploader sends a form when the method is :post. Its options are those of an upload URL before
(expires_in:, content_type:, size:, if_exists: and query:), and Fil.disk/1 takes signed_upload: with
defaults for expires_in: and if_exists:. Adapters sign uploads with the new optional callback c:Fil.Adapter.signed_upload/3 and say with c:Fil.Adapter.binds_uploads?/1 whether the storage enforces the signed
size and type, and plugins see uploads as the :signed_upload op.
(#42)
Fil.Adapter.Null is a disk that stores nothing: writes succeed and drop the content, and every file is missing.
It's for dry runs, environments with storage turned off and tests that don't read files back. It reads a stream to
the end, so a failing stream or a plugin that refuses the content still fails the write.
(#46)
Fil.Plugin.ReadOnly lets reads, listings and URLs pass and refuses every other operation (writes, deletes, copies
and moves within the disk, signed uploads) with Fil.AccessDeniedError and reason: :read_only. A copy to another
disk works. (#45)
Changed
Fil.signed_url/3 signs downloads only, and no longer takes method:, content_type:, size: or if_exists:.
Sign uploads with Fil.signed_upload/3 instead. The signed_url: option of Fil.disk/1 no longer takes if_exists:, which moved to signed_upload:. Fil.Plugin.Validation checks uploads on the :signed_upload op.
(#42)
Fil.InvalidRequestError is split by what the caller can do about it. A path the disk can't use (:ebadpath, :eisdir, :enotdir, a name that's too long, a symlink loop, S3's KeyTooLongError) is the new Fil.InvalidPathError. Content the disk refuses is a Fil.InvalidContentError wherever the refusal comes from:
content over the storage's size limit, :too_many_parts, Fil.Plugin.Thumbnails for a file that isn't an image,
and Fil.LiveView's :extension, :too_large, :size and :content_type. S3's InvalidRequest and Azure's InvalidHeaderValue, InvalidQueryParameterValue and OutOfRangeInput are a Fil.UnknownError. Fil.Plug keeps
its statuses, and answers a content error with the body "the content was rejected" wherever it comes from.
(#77)
Fil.Adapter.S3 handles a copy or a move onto itself like the other adapters: it leaves the file as it is, and
returns Fil.AlreadyExistsError with if_exists: :error, instead of S3's InvalidRequest.
(#77)
Fixed
Fil.Plug serves the right ranges with a plugin that changes the size of reads, once the plugin follows the new rule
for sizes: Fil.stat/3 and Fil.ls/3 report the size of the content as Fil.read/3 returns it, so such a plugin
sets size in its :stat and :ls results to the size it delivers, or to nil when it can't know it (see Ranges). A file without a size gets a 200 with the whole file and no accept-ranges, and Fil.LiveView no longer refuses a direct upload without a size as larger than max_file_size:.
(#75)
Security
Fil.Plug and Fil.Plug.send_file send x-content-type-options: nosniff with every response, and send HTML, XML,
SVG and JavaScript files, and files without a valid type, as application/octet-stream with content-disposition: attachment, so an uploaded file can't run scripts on your application's domain. With an inline disposition, such a file keeps its type and gets content-security-policy: sandbox, so the browser shows it
without running its scripts. The new active_types: option changes the list (Fil.Plug.default_active_types/0
returns the default), and active_types: [] sends every file as stored.
(#47)