How to use the activestorage.DirectUpload function in activestorage

To help you get started, we’ve selected a few 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 Sology / uppy-activestorage-upload / lib / index.js View on Github external
this.uppy.log(`[XHRUpload] ${id} progress: ${ev.loaded} / ${ev.total}`);
        timer.progress();

        if (ev.lengthComputable) {
          this.uppy.emit('upload-progress', file, {
            uploader: this,
            bytesUploaded: ev.loaded,
            bytesTotal: ev.total
          })
        }
      }
      directHandlers.directUploadWillStoreFileWithXHR = (request) => {
        request.upload.addEventListener("progress", event => directHandlers.directUploadDidProgress(event))
      }

      const upload = new DirectUpload(file.data, this.opts.directUploadUrl, directHandlers);
      const id = cuid();

      upload.create((error, blob) => {
        this.uppy.log(`[XHRUpload] ${id} finished`);
        timer.done();

        if(error) {
          const response = {
            status: 'error',
          };

          this.uppy.setFileState(file.id, { response });

          this.uppy.emit('upload-error', file, error);
          return reject(error);
        } else {
github huacnlee / bluedoc / app / javascript / bluedoc / editor / attachment-upload.js View on Github external
constructor(file, directUploadUrl, blobUrlTemplate, callback, progress) {
    this.file = file
    this.directUploadUrl = directUploadUrl
    this.blobUrlTemplate = blobUrlTemplate
    this.callback = callback
    this.progress = progress
    this.directUpload = new DirectUpload(file, this.directUploadUrl, this)
  }
github cbothner / react-activestorage-provider / src / Upload.js View on Github external
constructor(file: File, options: Options) {
    this.options = { ...Upload.defaultOptions, ...compactObject(options) }
    this.directUpload = new ActiveStorage.DirectUpload(
      file,
      this.directUploadsUrl,
      this
    )

    this.handleChangeFile({ state: 'waiting', id: this.id, file })
  }
github marinosoftware / active_storage_drag_and_drop / app / javascript / active_storage_drag_and_drop / drag_and_drop_upload_controller.js View on Github external
constructor (input: HTMLInputElement, file: File) {
    validate(input, file)
    const form = input.closest('form')
    const iconContainer = document.getElementById(input.dataset.iconContainerId)
    if (!(form instanceof HTMLFormElement && iconContainer)) return

    this.input = input
    this.form = form
    this.url = this.input.dataset.directUploadUrl
    this.iconContainer = iconContainer
    this.file = file
    this.upload = new DirectUpload(this.file, this.url, this)
    const event = this.dispatch('initialize')
    initializeUI(event)
  }
github huacnlee / bluedoc / app / javascript / bluedoc / comments / image_upload.js View on Github external
constructor(file, directUploadUrl, blobUrlTemplate, callback) {
    this.file = file
    this.directUploadUrl = directUploadUrl
    this.blobUrlTemplate = blobUrlTemplate
    this.callback = callback
    this.directUpload = new DirectUpload(file, this.directUploadUrl, this)
  }

activestorage

Attach cloud and local files in Rails applications

MIT
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis