Created
March 27, 2019 14:28
-
-
Save codessentials/0a439946c4635fc82be672f91618c201 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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