How to use activestorage - 10 common examples

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 archonic / limestone-accounts / app / javascript / packs / application.js View on Github external
import Rails from 'rails-ujs';
Rails.start();
window.Rails = Rails;
import Turbolinks from 'turbolinks';
window.Turbolinks = Turbolinks;
Turbolinks.start();

import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))

import * as ActiveStorage from "activestorage"
ActiveStorage.start()

// Does not process requires when imported like this
import '../packs/src/subscriptions'
import '../packs/src/modals'
import '../packs/src/global'
console.log('Hello World from Webpacker')
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)
  }
github getcampo / campo / app / webpacker / javascripts / application.js View on Github external
import Rails from "rails-ujs"
Rails.start()

import * as ActiveStorage from "activestorage"
ActiveStorage.start()

import Turbolinks from "turbolinks"
Turbolinks.start()

import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))

import "./cable"

import "./local_time"
github getcampo / campo / app / webpacker / javascripts / application.js View on Github external
import "bootstrap"

import Rails from "rails-ujs"
Rails.start()

import * as ActiveStorage from "activestorage"
ActiveStorage.start()

import Turbolinks from "turbolinks"
Turbolinks.start()

import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))

import "./cable"

import "./local_time"
github chaskiq / chaskiq / app / javascript / src / shared / fileUploader.js View on Github external
export const directUpload = (url, headers, file) => {
  const upload = new BlobUpload({ file, directUploadData: { url, headers } });
  return new Promise((resolve, reject) => {
    upload.create(error => {
      if (error) {
        reject(error);
      } else {
        resolve();
      }
    })
  });
};
github chaskiq / chaskiq / app / javascript / src / shared / fileUploader.js View on Github external
return new Promise((resolve, reject) => {
    FileChecksum.create(file, (error, checksum) => {
      if (error) {
        reject(error);
        return;
      }

      resolve(checksum);
    });
  });
}

activestorage

Attach cloud and local files in Rails applications

MIT
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis