How to use the @rails/activestorage/src/direct_upload.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 chaskiq / chaskiq / app / javascript / client_messenger / uploader.js View on Github external
return new Promise((resolve, reject)=> {
    
    if(props){
      props.onLoading()
      //props.change(previewField, '/spinner.gif')
    }

    const upload = new DirectUpload(
      file,
      `${props.domain}/api/v1/direct_uploads`
    )
    upload.create((error, blob)=>{
      if(error){
        alert("error uploading!")
        props.onError(error)
      } else {
        if(props){
          props.onSuccess(
            {link: blob.service_url}
          )
        }
        resolve({data: {...blob, link: blob.service_url}})
      }
    })

@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