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AC;QAChF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IACH,wBAAC;AAAD,CA9BA,AA8BC;AA7Be,yBAAO,GAAa,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAD7C,8CAAiB","file":"webparts/angularFileUpload/app/services/fileUploadSvc.js","sourcesContent":["import { BaseService } from \"./baseSvc\";\r\nimport { IFileItem } from \"../../interfaces/IFileItem\";\r\nimport { IFile } from \"../../interfaces/IFile\";\r\n\r\nexport class FileUploadService {\r\n public static $inject: string[] = [\"baseService\", \"$q\"];\r\n constructor(private baseService: BaseService, private $q: ng.IQService) {\r\n }\r\n\r\n public uploadFile(libraryName: string, file: IFile): ng.IPromise<IFileItem> {\r\n const deferred: ng.IDeferred<IFileItem> = this.$q.defer();\r\n var uploadUrl = `/_api/web/lists/getbytitle('${libraryName}')/rootfolder/files/add(url=@filename, overwrite=true)?@filename='${file.fileName}'`;\r\n this.baseService\r\n .postRequest(uploadUrl, file.fileAsBuffer)\r\n .then((response: any): ng.IPromise<IFileItem> => {\r\n return this.baseService\r\n .getRequest(null, `${response.d.ListItemAllFields.__deferred.uri}?$select=Id,Modified,FileLeafRef`);\r\n }).then((response: IFileItem): void => {\r\n deferred.resolve(response);\r\n }, (error: any): void => {\r\n deferred.reject(error);\r\n });\r\n return deferred.promise;\r\n }\r\n\r\n public getFiles(libraryName: string, rowLimit: number): ng.IPromise<Array<IFileItem>> {\r\n const url: string = `/_api/Web/lists/getbytitle('${libraryName}')/items?$select=Id,Modified,FileLeafRef,Author/Id&$expand=Author&$orderby=Modified desc&$top=${rowLimit}`;\r\n return this.baseService.getRequest(url);\r\n }\r\n\r\n public deleteFile(libraryName: string, id: number): ng.IPromise<any> {\r\n const url: string = `/_api/Web/lists/getbytitle('${libraryName}')/items(${id})`;\r\n return this.baseService.deleteRequest(url, \"*\");\r\n }\r\n}"],"sourceRoot":"..\\..\\..\\..\\..\\src"}
|