mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
shared conted ios
This commit is contained in:
@@ -749,6 +749,14 @@ export class NewPublicationPage implements OnInit {
|
|||||||
let FileExtension = this.removeTextBeforeSlash(element.title, '.')
|
let FileExtension = this.removeTextBeforeSlash(element.title, '.')
|
||||||
if (this.checkFileType.checkFileType(FileExtension) == 'image' || this.checkFileType.checkFileType(FileExtension) == 'video') {
|
if (this.checkFileType.checkFileType(FileExtension) == 'image' || this.checkFileType.checkFileType(FileExtension) == 'video') {
|
||||||
let resultUrl = decodeURIComponent(element.url);
|
let resultUrl = decodeURIComponent(element.url);
|
||||||
|
|
||||||
|
if(this.platform.is('ios')) {
|
||||||
|
this.shareContentIso(resultUrl,FileExtension)
|
||||||
|
} else {
|
||||||
|
this.shareContentAndroid(resultUrl,FileExtension)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||||
let fileObject;
|
let fileObject;
|
||||||
try {
|
try {
|
||||||
@@ -774,7 +782,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
console.log('error shared filesystem', error)
|
console.log('error shared filesystem', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}) */
|
||||||
} else {
|
} else {
|
||||||
this.httpErrorHandle.validationMessagge('filetype');
|
this.httpErrorHandle.validationMessagge('filetype');
|
||||||
}
|
}
|
||||||
@@ -901,5 +909,104 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async shareContentIso(fullPath,FileExtension) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
||||||
|
|
||||||
|
Filesystem.readFile({ path: fullPath }).then(async (content) => {
|
||||||
|
let fileObject;
|
||||||
|
try {
|
||||||
|
fileObject = {
|
||||||
|
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||||
|
FileExtension: FileExtension,
|
||||||
|
OriginalFileName: 'shared',
|
||||||
|
}
|
||||||
|
console.log('shared base', content.data)
|
||||||
|
|
||||||
|
this.seletedContent.push(fileObject)
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error shared filesystem', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
} else if (this.checkFileType.checkFileType(FileExtension) == 'video') {
|
||||||
|
const directory = await Filesystem.getUri({
|
||||||
|
directory: Directory.Cache,
|
||||||
|
path: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
let fileObject ={};
|
||||||
|
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4').then(() => {
|
||||||
|
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||||
|
|
||||||
|
.then(async (content) => {
|
||||||
|
console.log(content.data)
|
||||||
|
this.filecontent = true;
|
||||||
|
fileObject = {
|
||||||
|
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||||
|
FileExtension: FileExtension,
|
||||||
|
OriginalFileName: 'shared',
|
||||||
|
}
|
||||||
|
fileObject = {
|
||||||
|
FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','),
|
||||||
|
FileExtension: FileExtension,
|
||||||
|
OriginalFileName: 'shared',
|
||||||
|
}
|
||||||
|
this.seletedContent.push(fileObject)
|
||||||
|
fileObject ={};
|
||||||
|
const deleteSecretFile = async () => {
|
||||||
|
await Filesystem.deleteFile({
|
||||||
|
path: 'output.mp4',
|
||||||
|
directory: Directory.Cache,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
deleteSecretFile().then((value) => {
|
||||||
|
console.log('delete file',value)
|
||||||
|
fileObject ={};
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((erro) => console.error('read converted video erro ', erro));
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log('record video ios erro, ', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shareContentAndroid(resultUrl,FileExtension) {
|
||||||
|
|
||||||
|
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||||
|
let fileObject;
|
||||||
|
try {
|
||||||
|
if (this.checkFileType.checkFileType(FileExtension) == 'image') {
|
||||||
|
fileObject = {
|
||||||
|
FileBase64: this.removeTextBeforeSlash(content.data, ','),
|
||||||
|
FileExtension: FileExtension,
|
||||||
|
OriginalFileName: 'shared',
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (this.checkFileType.checkFileType(FileExtension) == 'video') {
|
||||||
|
fileObject = {
|
||||||
|
FileBase64: 'data:video/mp4;base64,' + this.removeTextBeforeSlash(content.data, ','),
|
||||||
|
FileExtension: FileExtension,
|
||||||
|
OriginalFileName: 'shared',
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log('shared base', content.data)
|
||||||
|
|
||||||
|
this.seletedContent.push(fileObject)
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error shared filesystem', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user