Skip to content

Commit a5d6620

Browse files
author
Adam Stauffer
committed
allow customization of http method (fix #45)
1 parent e425a10 commit a5d6620

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ npm i angular-file-uploader
5454
maxSize: "1",
5555
uploadAPI: {
5656
url:"https://example-file-upload-api",
57+
method:"POST",
5758
headers: {
5859
"Content-Type" : "text/plain;charset=UTF-8",
5960
"Authorization" : `Bearer ${token}`
@@ -88,6 +89,7 @@ npm i angular-file-uploader
8889
| formatsAllowed : string | Specify the formats of file you want to upload. | '.jpg,.png,.pdf,.docx, .txt,.gif,.jpeg'|
8990
| maxSize : number | Maximum size limit for files in MB. | 20 MB |
9091
| uploadAPI.url : string | Complete api url to which you want to upload. | undefined |
92+
| uploadAPI.method : string | HTTP method to use for upload. | POST |
9193
| uploadAPI.headers : {} | Provide headers you need here. | {} |
9294
| theme : string | Specify the theme name you want to apply. Available Themes: ' dragNDrop ', ' attachPin ' | If no theme or wrong theme is specified, default theme will be used instead.|
9395
| hideProgressBar:boolean | Set it as " true " to hide the Progress bar. | false |
@@ -213,6 +215,7 @@ npm i angular-file-uploader
213215
maxSize: "1",
214216
uploadAPI: {
215217
url:"https://example-file-upload-api",
218+
method:"POST",
216219
headers: {
217220
"Content-Type" : "text/plain;charset=UTF-8",
218221
"Authorization" : `Bearer ${token}`
@@ -238,6 +241,7 @@ npm i angular-file-uploader
238241
| formatsAllowed : string | Specify the formats of file you want to upload. | '.jpg,.png,.pdf,.docx, .txt,.gif,.jpeg'|
239242
| maxSize : number | Maximum size limit for files in MB. | 20 MB |
240243
| uploadAPI.url : string | Complete api url to which you want to upload. | undefined |
244+
| uploadAPI.method : string | HTTP method to use for upload. | POST |
241245
| uploadAPI.headers : {} | Provide headers you need here. | {} |
242246
| theme : string | Specify the theme name you want to apply. Available Themes: ' dragNDrop ', ' attachPin ' | If no theme or wrong theme is specified, default theme will be used instead.|
243247
| hideProgressBar:boolean | Set it as " true " to hide the Progress bar. | false |

projects/angular-file-uploader/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ npm i angular-file-uploader
5454
maxSize: "1",
5555
uploadAPI: {
5656
url:"https://example-file-upload-api",
57+
method:"POST",
5758
headers: {
5859
"Content-Type" : "text/plain;charset=UTF-8",
5960
"Authorization" : `Bearer ${token}`
@@ -88,6 +89,7 @@ npm i angular-file-uploader
8889
| formatsAllowed : string | Specify the formats of file you want to upload. | '.jpg,.png,.pdf,.docx, .txt,.gif,.jpeg'|
8990
| maxSize : number | Maximum size limit for files in MB. | 20 MB |
9091
| uploadAPI.url : string | Complete api url to which you want to upload. | undefined |
92+
| uploadAPI.method : string | HTTP method to use for upload. | POST |
9193
| uploadAPI.headers : {} | Provide headers you need here. | {} |
9294
| theme : string | Specify the theme name you want to apply. Available Themes: ' dragNDrop ', ' attachPin ' | If no theme or wrong theme is specified, default theme will be used instead.|
9395
| hideProgressBar:boolean | Set it as " true " to hide the Progress bar. | false |
@@ -213,6 +215,7 @@ npm i angular-file-uploader
213215
maxSize: "1",
214216
uploadAPI: {
215217
url:"https://example-file-upload-api",
218+
method:"POST",
216219
headers: {
217220
"Content-Type" : "text/plain;charset=UTF-8",
218221
"Authorization" : `Bearer ${token}`
@@ -238,6 +241,7 @@ npm i angular-file-uploader
238241
| formatsAllowed : string | Specify the formats of file you want to upload. | '.jpg,.png,.pdf,.docx, .txt,.gif,.jpeg'|
239242
| maxSize : number | Maximum size limit for files in MB. | 20 MB |
240243
| uploadAPI.url : string | Complete api url to which you want to upload. | undefined |
244+
| uploadAPI.method : string | HTTP method to use for upload. | POST |
241245
| uploadAPI.headers : {} | Provide headers you need here. | {} |
242246
| theme : string | Specify the theme name you want to apply. Available Themes: ' dragNDrop ', ' attachPin ' | If no theme or wrong theme is specified, default theme will be used instead.|
243247
| hideProgressBar:boolean | Set it as " true " to hide the Progress bar. | false |

projects/angular-file-uploader/src/lib/angular-file-uploader.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class AngularFileUploaderComponent implements OnInit, OnChanges {
1717
hideProgressBar: boolean;
1818
maxSize: number;
1919
uploadAPI: string;
20+
method: string;
2021
formatsAllowed: string;
2122
multiple: boolean;
2223
headers: any;
@@ -57,6 +58,7 @@ export class AngularFileUploaderComponent implements OnInit, OnChanges {
5758
this.hideSelectBtn = this.config["hideSelectBtn"] || false;
5859
this.maxSize = this.config["maxSize"] || 20;
5960
this.uploadAPI = this.config["uploadAPI"]["url"];
61+
this.method = this.config["uploadAPI"]["method"] || "POST";
6062
this.formatsAllowed =
6163
this.config["formatsAllowed"] || ".jpg,.png,.pdf,.docx,.txt,.gif,.jpeg";
6264
this.multiple = this.config["multiple"] || false;
@@ -266,7 +268,7 @@ export class AngularFileUploaderComponent implements OnInit, OnChanges {
266268
//console.log(evnt);
267269
};
268270

269-
xhr.open("POST", this.uploadAPI, true);
271+
xhr.open(this.method, this.uploadAPI, true);
270272
for (const key of Object.keys(this.headers)) {
271273
// Object.keys will give an Array of keys
272274
xhr.setRequestHeader(key, this.headers[key]);

0 commit comments

Comments
 (0)