Merge pull request #51893 from indigotechtutorials/main

Fix the Direct Upload class example in Active Storage Docs [ci skip]
This commit is contained in:
Carlos Antonio da Silva 2024-05-23 17:14:09 -03:00 committed by GitHub
commit be2ecdf26d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1302,10 +1302,10 @@ import { DirectUpload } from "@rails/activestorage"
class Uploader {
constructor(file, url) {
this.upload = new DirectUpload(this.file, this.url, this)
this.upload = new DirectUpload(file, url, this)
}
upload(file) {
uploadFile(file) {
this.upload.create((error, blob) => {
if (error) {
// Handle the error
@ -1342,10 +1342,10 @@ class Uploader {
const headers = { 'Authentication': `Bearer ${token}` }
// INFO: Sending headers is an optional parameter. If you choose not to send headers,
// authentication will be performed using cookies or session data.
this.upload = new DirectUpload(this.file, this.url, this, headers)
this.upload = new DirectUpload(file, url, this, headers)
}
upload(file) {
uploadFile(file) {
this.upload.create((error, blob) => {
if (error) {
// Handle the error