mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Minor constructor signature tweaks
This commit is contained in:
parent
a0a23e9f5d
commit
b0b072ff2e
4 changed files with 12 additions and 8 deletions
File diff suppressed because one or more lines are too long
|
@ -5,16 +5,15 @@ import { BlobUpload } from "./blob_upload"
|
|||
let id = 0
|
||||
|
||||
export class DirectUpload {
|
||||
constructor(file, options = {}) {
|
||||
this.id = id++
|
||||
constructor(file, url, delegate) {
|
||||
this.id = ++id
|
||||
this.file = file
|
||||
this.url = options.url
|
||||
this.delegate = options.delegate
|
||||
this.url = url
|
||||
this.delegate = delegate
|
||||
}
|
||||
|
||||
create(callback) {
|
||||
const fileChecksum = new FileChecksum(this.file)
|
||||
fileChecksum.create((error, checksum) => {
|
||||
FileChecksum.create(this.file, (error, checksum) => {
|
||||
const blob = new BlobRecord(this.file, checksum, this.url)
|
||||
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr)
|
||||
blob.create(error => {
|
||||
|
|
|
@ -5,7 +5,7 @@ export class DirectUploadController {
|
|||
constructor(input, file) {
|
||||
this.input = input
|
||||
this.file = file
|
||||
this.directUpload = new DirectUpload(this.file, { url: this.url, delegate: this })
|
||||
this.directUpload = new DirectUpload(this.file, this.url, this)
|
||||
this.dispatch("initialize")
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@ import SparkMD5 from "spark-md5"
|
|||
const fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
|
||||
|
||||
export class FileChecksum {
|
||||
static create(file, callback) {
|
||||
const instance = new FileChecksum(file)
|
||||
instance.create(callback)
|
||||
}
|
||||
|
||||
constructor(file) {
|
||||
this.file = file
|
||||
this.chunkSize = 2097152 // 2MB
|
||||
|
|
Loading…
Reference in a new issue