How to use the @rails/activestorage.DirectUpload function in @rails/activestorage

To help you get started, we’ve selected a few @rails/activestorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github connorshea / vglist / app / javascript / src / components / avatar-input.vue View on Github external
uploadFile(file) {
      this.existingAvatar = null;
      const url = this.railsDirectUploadsPath;
      const upload = new DirectUpload(file, url, {
        directUploadWillStoreFileWithXHR: (xhr) => {
          // Use this workaround to make sure that Direct Upload-ed images are
          // uploaded with the correct header. Otherwise they will end up being
          // private files.
          xhr.setRequestHeader('x-amz-acl', 'public-read');
        }
      });

      upload.create((error, blob) => {
        if (error) {
          // TODO: Handle this error.
          console.log(error);
        } else {
          this.avatarBlob = blob.signed_id;
        }
      });
github connorshea / vglist / app / javascript / src / components / game-form.vue View on Github external
uploadFile(file) {
      const url = this.railsDirectUploadsPath;
      const upload = new DirectUpload(file, url, {
        directUploadWillStoreFileWithXHR: (xhr) => {
          // Use this workaround to make sure that Direct Upload-ed images are
          // uploaded with the correct header. Otherwise they will end up being
          // private files.
          xhr.setRequestHeader('x-amz-acl', 'public-read');
        }
      });

      upload.create((error, blob) => {
        if (error) {
          // TODO: Handle this error.
          console.log(error);
        } else {
          this.game.coverBlob = blob.signed_id;
        }
      });
github rails / rails / actiontext / app / javascript / actiontext / attachment_upload.js View on Github external
constructor(attachment, element) {
    this.attachment = attachment
    this.element = element
    this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this)
  }

@rails/activestorage

Attach cloud and local files in Rails applications

MIT
Latest version published 6 days ago

Package Health Score

98 / 100
Full package analysis

Similar packages