2017-08-10 41 views
0

私はBASE64に画像のURLを変換するにはどうすればよいのヘルプ、(イオン2)どのように私はあなたがこのようにそれを行うことができます

this.camera.getPicture({ 


sourceType: this.camera.PictureSourceType.PHOTOLIBRARY, 
    destinationType: this.camera.DestinationType.FILE_URI, 
    quality: 100, 
    encodingType: this.camera.EncodingType.PNG, 
}).then(imageData => { 
    console.log('THIS IS THE URI ' + imageData); 
    //How do I get the image and convert it to base64 ? 
}, error => { 
    this.error = JSON.stringify(error); 
}); 
+0

解決策はあなたのために機能しましたか? –

答えて

0

(イオン2)をbase64に画像のURLを変換することができます。

3つのオプション次
this.camera.getPicture({ 
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY, 
    destinationType: this.camera.DestinationType.DATA_URL, 
    quality: 100, 
    encodingType: this.camera.EncodingType.PNG, 
}).then(imageData => { 
    console.log('THIS IS THE Base64' + imageData); 
    let base64Image = 'data:image/jpeg;base64,' + imageData; 
}, error => { 
    this.error = JSON.stringify(error); 
}); 

destinationTypeのサポート:

  1. DATA_URL:Base64でエンコードされた文字列を返します。 DATA_URLは大量のメモリを必要とするため、アプリがクラッシュしたり、メモリ不足が発生する可能性があります。使用FILE_URIまたはNATIVE_URI可能であれば
  2. FILE_URI:リターンファイルURI(コンテンツ:Android用//メディア/外部/画像/メディア/ 2)
  3. NATIVE_URI:ネイティブURIを返します(たとえば、資産ライブラリ。: // ... for iOS)
関連する問題