Sha256: 4eeda4ac82169d1a8215b5cd7c9f4ccafcb92900c01036f847278e4424a990d5
Contents?: true
Size: 1.3 KB
Versions: 5
Compression:
Stored size: 1.3 KB
Contents
import { FileChecksum } from "./file_checksum" import { BlobRecord } from "./blob_record" import { BlobUpload } from "./blob_upload" let id = 0 export class DirectUpload { constructor(file, url, serviceName, attachmentName, delegate) { this.id = ++id this.file = file this.url = url this.serviceName = serviceName this.attachmentName = attachmentName this.delegate = delegate } create(callback) { FileChecksum.create(this.file, (error, checksum) => { if (error) { callback(error) return } const blob = new BlobRecord(this.file, checksum, this.url, this.serviceName, this.attachmentName) notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr) blob.create(error => { if (error) { callback(error) } else { const upload = new BlobUpload(blob) notify(this.delegate, "directUploadWillStoreFileWithXHR", upload.xhr) upload.create(error => { if (error) { callback(error) } else { callback(null, blob.toJSON()) } }) } }) }) } } function notify(object, methodName, ...messages) { if (object && typeof object[methodName] == "function") { return object[methodName](...messages) } }
Version data entries
5 entries across 5 versions & 1 rubygems