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
@Injectable() | |
export class UploadService { | |
/** | |
* @param Observable<number> | |
*/ | |
private progress$: Observable<number>; | |
/** | |
* @type {number} | |
*/ |
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
let header = this._variableService.getToken(); | |
let input = new FormData(); | |
input.append("username", this.profileForm.controls['username'].value); | |
input.append("status", this.profileForm.controls['status'].value); | |
input.append("city", this.profileForm.controls['city'].value); | |
input.append("want_news", this.profileForm.controls['want_news'].value); | |
input.append("want_notifications", this.profileForm.controls['want_notifications'].value); | |
if (this.result !== null) { |
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
class ProfileImageUploadView(views.APIView): | |
parser_classes = (FileUploadParser,) | |
permission_classes = (IsAccountOwner,) | |
def put(self, request, filename, format=None): | |
file_obj = request.data['file'] | |
if not request.user.is_anonymous(): | |
profile = request.user.profile | |
profile.profile_image = file_obj | |
profile.save() |
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
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) |
NewerOlder