0
A
答えて
2
プラグインコードバープラグインファイル転送https://github.com/apache/cordova-plugin-file-transferを使用すると、サーバーからファイルをダウンロードできます。
vcfファイルを読むには、https://github.com/nilclass/vcardjs JavaScriptベースのライブラリが必要です。 .jsファイルを直接使用することができます。
以下の例に従うことができます。
window.requestFileSystem(window.TEMPORARY, 1 * 1024 * 1024, function (fs) {
console.log('file system open: ' + fs.name);
var fileName = "temp.vcf";
var dirEntry = fs.root;
dirEntry.getFile(fileName, { create: true, exclusive: false }, function (fileEntry) {
download(fileEntry,"server-path-to-file.vcf");
}, onErrorCreateFile);
}, onErrorLoadFs);
function download(fileEntry, uri) {
var fileTransfer = new FileTransfer();
var fileURL = fileEntry.toURL();
fileTransfer.download(
uri,
fileURL,
function (entry) {
console.log("Successful download...");
console.log("download complete: " + entry.toURL());
readFile(entry);
},
function (error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
null, // or, pass false
{
//headers: {
// "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
//}
}
);
}
function readFile(fileEntry) {
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function() {
console.log("Successful file read: " + reader.result);
reader.parseVCard(reader.result);
};
reader.readAsText(file);
}, onErrorReadFile);
}
function parseVCard(vCarddata){
VCF.parse(vCarddata, function(vcard) {
// this function is called with a VCard instance.
// If the input contains more than one vCard, it is called multiple times.
console.log("Formatted name", vcard.fn);
console.log("Names", JSON.stringify(vcard.n));
});
//Fore more help:https://github.com/nilclass/vcardjs
}
関連する問題
- 1. pysparkをSQLサーバから読み取る
- 2. Apache Httpクライアントは、 "[読み取り] I/Oエラー:読み取りタイムアウト" "
- 3. サーバからの端末出力のリアルタイム読み取り
- 4. OPCクライアント - リモートOPCサーバからの読み取り方法
- 5. 読み取り
- 6. 読み取り
- 7. 読み取りまたは
- 8. は読み取りプログラム
- 9. は、読み取りエラー
- 10. 読み取りExtendedPropertiesは、アドイン
- 11. は読み取り専用
- 12. pythonマルチスレッドは、読み取り専用メモリバッファバイパスを読み取るGIL
- 13. 読み取りが
- 14. 読み取り - R
- 15. 読み取りエラーデバイスドライバ
- 16. 読み取りデータ
- 17. 読み取りファイル
- 18. 読み取りハンドルエラー
- 19. 読み取りダブル
- 20. 読み取り/フィルター
- 21. 読み取りXML
- 22. 読み取り/アンドロイド
- 23. カーネル読み取り/
- 24. 読み取りテキストファイル
- 25. com.google.cloud.bigquery.BigQueryException:読み取り
- 26. 読み取り前に読み取り修復をスケジュールする
- 27. 読み取り専用トランザクション - タイムスタンプバウンドの読み取りのパフォーマンス
- 28. 読み取り専用自動対(読み取り専用)プロパティ
- 29. open loop on oracle:検索する;現在の読み取り、次の読み取り、最後の読み取り?
- 30. サーバからこのjsonデータを読み取るには?
........このソリューションは罰金:-) – Bunny
..このソリューションを試してみて、あなたが知っているだろう:) – Bunny
は素晴らしい作品 –