Skip to content

Commit

Permalink
fix: missing global metadata option
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Mar 12, 2019
1 parent 2dfca70 commit d868e78
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/directive-way/directive-way.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class DirectiveWayComponent implements OnDestroy {
token: () => {
return 'sometoken';
},
metadata: (f: File) => ({ title: f.name }),
autoUpload: true,
withCredentials: false,
chunkSize: 1024 * 256 * 8,
Expand Down
8 changes: 7 additions & 1 deletion src/uploadx/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface UploadItem {
* @defaultValue
* { name: File.Filename, mimeType: File.type }
*/
metadata?: any;
metadata?: { [key: string]: any } | ((file?: File) => { [key: string]: any });
/**
* Authorization Bearer token
*/
Expand Down Expand Up @@ -116,6 +116,12 @@ export class UploadxOptions {
* @defaultValue 'POST'
*/
method?: string;
/**
* Upload meta
* @defaultValue
* { name: File.Filename, mimeType: File.type }
*/
metadata?: { [key: string]: any } | ((file?: File) => { [key: string]: any });
/**
* Authorization Bearer token
*/
Expand Down
2 changes: 1 addition & 1 deletion src/uploadx/src/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class Uploader {
resolve();
};
xhr.onerror = () => reject();
const body = typeof payload === 'object' ? JSON.stringify(payload) : null;
const body = payload ? JSON.stringify(payload) : null;
xhr.send(body);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/uploadx/src/uploadx.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class UploadxService {
// tslint:disable-next-line: deprecation
endpoint: this.options.endpoint || this.options.url || '/upload/',
headers: this.options.headers,
metadata: this.options.metadata,
token: this.options.token,
chunkSize: this.options.chunkSize,
withCredentials: this.options.withCredentials,
Expand Down

0 comments on commit d868e78

Please sign in to comment.