2017-09-19 16 views
0

私はこのアプリケーションでOutlookやGMAILからionic 2で開いた特定の添付ファイルファイルを作成します。私はのmanifest.xmlで次のように指定します。Web-Intentとionic 2/angular 2でOutlookから添付ファイルを取得

<intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
     <data android:mimeType="*/*" /> 
     <data android:pathPattern="*.*\\.yxc" /> 
</intent-filter> 
<intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
     <data android:scheme="file" /> 
     <data android:mimeType="*/*" /> 
     <data android:host="*" /> 
     <data android:pathPattern=".*\\.yxc" /> 
</intent-filter> 

そして、私のapp.component.tsに私はと得る:

window['plugins'].intentShim.getIntent(
    function(intent) 
    { 
    console.log(intent); 

    }, 
    function() 
    { 
    console.log('Error getting launch intent'); 
    }); 

ファイルに次のパス:

content://com.microsoft.office.outlook.fileprovider/outlookfile/data/data/com.microsoft.office.outlook/app_1-MD5-328ccc4a44361ab118f13f707dc9609b/FileName.yxc 

しかし、どのように私はこのファイルとパスを扱うことができますか?ここで

答えて

0

私のソリューションです:

からインスピレーションを得た
if (pathName.startsWith('content://')) { 

this.filePath.resolveNativePath(InfoIQO.path) 
    .then((result) => { 

     let resultPath = result.substr(0, result.lastIndexOf('/')); 
     let resultFilename = result.substr(result.lastIndexOf('/') + 1, result.length); 

     this.readAsBinaryFile(resultPath, resultFilename); 
     loader.dismiss(); 

    }) 
    .catch((error) => { 
     console.log(error); 
    }) 

} 

readAsBinaryFile(path: string, file: string) { 

    this.file.readAsBinaryString(path, file) 
     .then((binaryContent) => { 

      console.log(binaryContent); 
     .catch((error) => { 
      console.log(error) 
     }) 

} 

Phonegap: Resolving content:// URI obtained from native file chooser

関連する問題