1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #40731 from ghiculescu/patch-2

ActiveStorage Direct Upload docs improvements [ci skip]
This commit is contained in:
Rafael França 2020-12-03 10:49:08 -05:00 committed by GitHub
commit cafdd18721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -618,12 +618,18 @@ directly from the client to the cloud.
ActiveStorage.start() ActiveStorage.start()
``` ```
2. Annotate file inputs with the direct upload URL. 2. Add `direct_upload: true` to your [`file_field`](form_helpers.html#uploading-files).
```erb ```erb
<%= form.file_field :attachments, multiple: true, direct_upload: true %> <%= form.file_field :attachments, multiple: true, direct_upload: true %>
``` ```
If you aren't using a [FormBuilder](form_helpers.html#customizing-form-builders), add the data attribute directly:
```erb
<input type=file data-direct-upload-url="<%= rails_direct_uploads_url %>" />
```
3. Configure CORS on third-party storage services to allow direct upload requests. 3. Configure CORS on third-party storage services to allow direct upload requests.
4. That's it! Uploads begin upon form submission. 4. That's it! Uploads begin upon form submission.