Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codessentials/0a439946c4635fc82be672f91618c201 to your computer and use it in GitHub Desktop.
Save codessentials/0a439946c4635fc82be672f91618c201 to your computer and use it in GitHub Desktop.
private storeMedia(systemNumber: string, picture: Media, imageData: string, uploadFileName: string, asThumb: boolean): Promise<any> {
const extension = uploadFileName.substring(uploadFileName.lastIndexOf('.') + 1, uploadFileName.length);
let fileName = picture.mediaType + '-' + (picture.creationDate || new Date()).getTime() + '.' + extension;
fileName = asThumb ? 'thumb-' + fileName : fileName;
const filePath = 'M' + systemNumber + '/' + fileName;
console.log('Saving media at', filePath, 'size', imageData.length);
const tmpParts = imageData.split('/');
const tmpFileName = tmpParts.pop();
const tmpFolder = tmpParts.join('/');
return this.file.copyFile(tmpFolder, tmpFileName, this.file.dataDirectory, filePath);
// return this.file.writeFile(this.file.dataDirectory, filePath, imageData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment