Commit 81050901 by Matteo

Condivisione direttamente con url

parent a1f8bfde
...@@ -179,6 +179,8 @@ export class UtilService { ...@@ -179,6 +179,8 @@ export class UtilService {
} }
fileScaricati: Array<string>; fileScaricati: Array<string>;
datiScaricati: Array<Blob>;
files: Array<Pair>;
count: number; count: number;
total: number; total: number;
...@@ -186,6 +188,8 @@ export class UtilService { ...@@ -186,6 +188,8 @@ export class UtilService {
{ {
this.count = 0; this.count = 0;
this.fileScaricati = new Array(); this.fileScaricati = new Array();
this.datiScaricati = new Array();
this.files = fileSel;
this.showLoading(); this.showLoading();
/*var i = 0; /*var i = 0;
while(i < fileSel.length) while(i < fileSel.length)
...@@ -221,25 +225,31 @@ export class UtilService { ...@@ -221,25 +225,31 @@ export class UtilService {
}, 1000); }, 1000);
else{ else{
this.closeLoading(); this.closeLoading();
this.socialSharing.share(null, null, this.fileScaricati, null).then(() => { this.socialSharing.share(null, null, this.fileScaricati, null).then(() => {
console.log("File condiviso con successo!"); console.log("File condiviso con successo!");
}).catch((e) => { }).catch((e) => {
this.presentAlert("Avviso", "", 'Errore durante la condivisione dei file', ["OK"]); this.presentAlert("Avviso", "", 'Errore durante la condivisione dei file', ["OK"]);
console.log('Errore durante la condivisione dei file:' + e); console.log('Errore durante la condivisione dei file:' + e);
}); });
} }
} }
async saveFile(fileInfo: Pair, index) async saveFile(fileInfo: Pair, index)
{ {
var path = ""; var path = "";
if(this.platform.is("ios")) path = this.file.tempDirectory; if(this.platform.is("ios")) path = this.file.dataDirectory;
else path = this.file.externalDataDirectory; else path = this.file.externalDataDirectory;
var nomeFile : string = fileInfo.key; var nomeFile : string = fileInfo.key;
nomeFile = nomeFile.replace(/\//g, "-"); nomeFile = nomeFile.replace(/\//g, "-");
await this.download(fileInfo.value) await this.download(fileInfo.value)
.subscribe( .subscribe(
(data) => { // Success (data) => { // Success
if(this.platform.is("ios"))
{
this.fileScaricati.push(fileInfo.value);
this.count++;
}
else
this.file.writeFile(path, nomeFile, data, { replace: true }).then((fileEntry: FileEntry) => { this.file.writeFile(path, nomeFile, data, { replace: true }).then((fileEntry: FileEntry) => {
this.fileScaricati.push(fileEntry.toURL()); this.fileScaricati.push(fileEntry.toURL());
this.count++; this.count++;
...@@ -256,7 +266,7 @@ export class UtilService { ...@@ -256,7 +266,7 @@ export class UtilService {
shareDocumento(fileUrl: string, nomeFile: string) shareDocumento(fileUrl: string, nomeFile: string)
{ {
var path = ""; var path = "";
if(this.platform.is("ios")) path = this.file.tempDirectory; if(this.platform.is("ios")) path = this.file.dataDirectory;
else path = this.file.externalDataDirectory; else path = this.file.externalDataDirectory;
nomeFile = nomeFile.replace(/\//g, "-"); nomeFile = nomeFile.replace(/\//g, "-");
this.showLoading(); this.showLoading();
...@@ -283,7 +293,7 @@ export class UtilService { ...@@ -283,7 +293,7 @@ export class UtilService {
downloadDocumento(fileUrl: string, nomeFile: string) downloadDocumento(fileUrl: string, nomeFile: string)
{ {
var path = ""; var path = "";
if(this.platform.is("ios")) path = this.file.tempDirectory; if(this.platform.is("ios")) path = this.file.dataDirectory;
else path = this.file.externalDataDirectory; else path = this.file.externalDataDirectory;
nomeFile = nomeFile.replace(/\//g, "-"); nomeFile = nomeFile.replace(/\//g, "-");
this.showLoading(); this.showLoading();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment