Created
August 9, 2017 10:07
-
-
Save AndreasDickow/9d5fcd2c608b4726d16dda37cc880a7b to your computer and use it in GitHub Desktop.
Ionic2 File Upload to Django Rest Framework
This file contains 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
let options: FileUploadOptions = { | |
fileKey: 'image', | |
fileName: this.result.substr(this.result.lastIndexOf('/') + 1), | |
mimeType : 'image/jpeg', | |
httpMethod : "PUT", | |
headers: {Authorization: this._variableService.getToken(),} | |
} | |
const fileTransfer: FileTransferObject = this.transfer.create(); | |
fileTransfer.upload(this.result, encodeURI(this._variableService.getBaseUrl() + '/api/v2/profile_image/'+this.result.substr(this.result.lastIndexOf('/') + 1)), options) | |
.then((data) => { | |
console.log(data); | |
}, (err) => { | |
console.log(err); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment