NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

Upload not working at all #247

Closed Justicea83 closed 5 years ago

Justicea83 commented 5 years ago

Heres my code

let session = backgroundHttp.session(this.walletService.uuidv4()); let request = { url: ${this.authService.baseUrl}/log-fund, method: "POST", headers: { "Content-Type": "application/octet-stream", "Authorization": Bearer ${this.user.token} }, description: "Uploading " + this.uploadName }; const params = [ { name: "amount", value: this.amount.toString() }, { name: "payable", value: this.amount.toString() }, { name: "account", value: 'normal' }, { name: "reference", value: this.walletService.uuidv4() }, { name: "type", value: 'bank' }, { name: "bank_id", value: this.selectedBank.id.toString() }, { name: "pop", filename: this.imageUpload.toString() } ]; const task = session.multipartUpload(params,request); task.on("progress", (args) => { // console.log(args) }); task.on("error", (error) => { console.log('error'); console.log(error.response); console.log(error.responseCode) }); task.on("complete", (resp) => { //console.log(resp) console.log('complete') });

Justicea83 commented 5 years ago

the responseCode is -1 and the error response is null

acharyaks90 commented 5 years ago

{ name: "fileToUpload", filename: file, mimeType: "image/jpeg" } Check the filename. file should be file path check. Console log path Response code -1 file not found or network error or server error. First try to upload any image file.

Justicea83 commented 5 years ago

Is the mimeType required /storage/emulated/0/Download/adult-adventure-back-view-2819546.jpg is the file path { name: "fileToUpload", filename: file, mimeType: "image/jpeg" } and is it required for the object to have this exact names?

Justicea83 commented 5 years ago

what will be the mimeType fo pdfs and MS word documents?

Justicea83 commented 5 years ago

I also dont really get the content-type property

support[bot] commented 5 years ago

:wave: @Justicea83, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please, use Stackoverflow to get help.