Files
danbooru/app/components/file_upload_component.rb
evazion 202dfe5d87 uploads: allow uploading multiple files from your computer at once.
Allow uploading multiple files from your computer at once.

The maximum limit is 100 files at once. There is still a 50MB size limit
that applies to the whole upload. This limit is at the Nginx level.

The upload widget no longer shows a thumbnail preview of the uploaded
file. This is because there isn't room for it in a multi-file upload,
and because the next page will show a preview anyway after the files are
uploaded.

Direct file uploads are processed synchronously, so they may be slow.

API change: the `POST /uploads` endpoint now expects the param to be
`upload[files][]`, not `upload[file]`.
2022-02-19 00:00:56 -06:00

24 lines
1.2 KiB
Ruby

# frozen_string_literal: true
# A component for uploading files to Danbooru. Used on the /uploads/new page.
class FileUploadComponent < ApplicationComponent
attr_reader :url, :referer_url, :drop_target, :max_file_size, :max_files_per_upload
# @param url [String] Optional. The URL to upload. If present, the URL field
# will be prefilled in the widget and the upload will be immediately triggered.
# @param referer_url [String] Optional. The referrer URL passed by the bookmarklet.
# @param drop_target [String] A CSS selector. The target for drag and drop
# events. If "body", then files can be dropped anywhere on the page, not
# just on the upload widget itself.
# @param max_file_size [Integer] The max size in bytes of an upload.
# @param max_files_per_upload [Integer] The maximum number of files per upload.
def initialize(url: nil, referer_url: nil, drop_target: nil, max_file_size: Danbooru.config.max_file_size, max_files_per_upload: Upload::MAX_FILES_PER_UPLOAD)
@url = url
@referer_url = referer_url
@drop_target = drop_target
@max_file_size = max_file_size
@max_files_per_upload = max_files_per_upload
super
end
end