@myog-io/ngx-chunk-file-upload-base
Version:
Angular file upload directives with Chunk Upload
62 lines (57 loc) • 1.54 kB
text/typescript
import { Injectable } from '@angular/core';
//import {
// FileUploaderService,
// FileItem,
// FileUploaderOptions,
// UploaderServiceOptions,
// UploaderLinksOptions,
//} from '@myog-io/ngx-chunk-file-upload';
import {
FileUploaderService,
FileItem,
FileUploaderOptions,
UploaderServiceOptions,
UploaderLinksOptions,
} from '../../../../../src/ngx-chunk-file-upload';
import { HttpClient } from '@angular/common/http';
const URL = '/api/';
//const URL = 'https://evening-anchorage-3159.herokuapp.com/api/';
()
export class SimpleDemoService extends FileUploaderService {
public links: UploaderLinksOptions = {
downloadEntry: URL + '#id#/',
updateEntry: URL + '#id#/',
createEntry: URL + '',
deleteEntry: URL + '#id#/',
};
public options: UploaderServiceOptions = {
createMethod: 'POST',
updateMethod: 'PATCH',
authorizationHeaderName: 'Authorization',
tokenPattern: 'Bearer #token#',
token: null,
chunkSize: 1024 * 1024 * 3,
totalChunkParamName: 'total_chunks',
currentChunkParamName: 'current_chunk',
fileParamName: 'file',
idAttribute: 'id',
};
constructor(protected http: HttpClient) {
super(http);
}
/**
* Determines whether before upload on
* Place your Authentiaction Tactics here
* @param item
* @param options
* @returns before upload
*/
public onBeforeUpload(
item: FileItem,
options: FileUploaderOptions,
): Promise<any> {
return new Promise((resolve, reject) => {
resolve(true);
});
}
}