Created
May 19, 2017 21:56
-
-
Save rquast/16debed7dec125ab6b9e76ede3100036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attached() { | |
this.fu = new qq.FineUploaderBasic({ | |
// button: document.getElementById('uploadButton'), | |
request: { | |
endpoint: '/api/upload', | |
inputName: 'qqfile' | |
}, | |
validation: { | |
// acceptFiles: ['image/jpeg', 'image/jpg', 'image/png', 'application/pdf'], | |
// allowedExtensions: ['jpeg', 'jpg', 'pdf', 'png'], | |
// itemLimit: 1, | |
sizeLimit: 8500000000 | |
}, | |
chunking: { | |
enabled: true, | |
concurrent: { | |
enabled: true | |
}, | |
success: { | |
endpoint: '/api/uploaddone' | |
} | |
}, | |
paramsInBody: true, | |
callbacks: { | |
onSubmit: (id, fileName) => { | |
this.stats = 'Uploading'; | |
this.uploadSpeeds = []; | |
if (this.$parent !== undefined && this.$parent.showChatInput) { | |
this.fu.setCustomHeaders(CavyConnect.headers({})); | |
this.fu.setParams(this.getParams()); | |
} else { | |
this.logError('Start or select a conversation before sending files.'); | |
return false; | |
} | |
}, | |
onUpload: (id, fileName) => { | |
this.completed = 0; | |
this.showStatus = true; | |
}, | |
onProgress: (id, name, uploadedBytes, totalBytes) => { | |
this.completed = Math.ceil(uploadedBytes / totalBytes * 100); | |
this.updateSpeedText(uploadedBytes, totalBytes); | |
}, | |
onComplete: (id, name, responseJSON, xhr) => { | |
this.showStatus = false; | |
if (!responseJSON.success) { | |
this.logError(responseJSON.error); | |
} | |
}, | |
onError: (id, name, errorReason, xhr) => { | |
this.showStatus = false; | |
this.logError(errorReason); | |
}, | |
onCancel: (id, name) => { | |
this.showStatus = false; | |
this.logInfo('Upload Cancelled'); | |
}, | |
onAutoRetry: (id, name, attemptNumber) => { | |
this.logInfo('Retrying Upload'); | |
} | |
}, | |
debug: false | |
}); | |
this.uploadFileForm = document.createElement('form'); | |
this.uploadFileEl = document.createElement('input'); | |
this.uploadFileEl.type = 'file'; | |
this.uploadFileForm.appendChild(this.uploadFileEl); | |
this.uploadFileForm.addEventListener('change', this.changeFn, false); | |
this.initFileDrop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment