valor-software / ng2-file-upload

Easy to use Angular components for files upload
http://valor-software.github.io/ng2-file-upload/
MIT License
1.91k stars 662 forks source link

how i use with web api service #541

Closed plima2050 closed 7 years ago

plima2050 commented 7 years ago

I need to send file to web api services restfull. please help me

hetzbr commented 7 years ago

Set the URL: let URL = 'My API End Point'; public uploader:FileUploader = new FileUploader({ url: URL, headers: [{ ... }], });

aviforgit commented 7 years ago

this.uploader = new FileUploader({ url: apiUrl + '/Student/UploadImage', authTokenHeader: user.access_token, authToken: user.access_token, headers: [ { name: 'Authorization', value: 'bearer '+user.access_token } ], queueLimit: 1 });

plima2050 commented 7 years ago

Thanks. @hetzbr, @aviforgit. Shared it work fine me. this.uploaderOptions['url'] = URL; this.uploaderOptions['method'] = 'POST'; this.uploaderOptions['autoUpload'] = false; this.uploader.setOptions(this.uploaderOptions);

Spawnrad commented 7 years ago
uploader: FileUploader;    
options: FileUploaderOptions = {
        url: '/api/file',
        authToken: 'Bearer ' + Utils.getToken(),
        authTokenHeader: 'Authorization',
    };

ngOnInit() {
        this.uploader = new FileUploader(this.options);
}