私は、HTML/Javascriptで書かれたUWPアプリを持っていて、JSZipから作られたzipファイルを保存するのに問題があります。具体的にディスクに書き込むのは、私がハングアップしているところです。UWPディスクにzipファイルを保存しています
WriteBufferAsync、WriteBytesAsync、WriteLinesAsync、およびWriteTextAsyncがあることをMicrosoftのドキュメントに見ています。私がこれに必要なものは何かわからない。また、JSZipは、base64、binarystring、uint8array、arraybuffer、およびblobのような異なるタイプを生成できます。私はこのzipファイルをユーザーのディスクに書き込むためにどのような組み合わせが必要なのか分かりません。以下は
私のコードです:
savePNGButton.addEventListener('click', function (e) {
var zip = new JSZip();
if (WatermarkText === ""){
ZipFolder = zip.folder("ImageFolder");
} else {
ZipFolder = zip.folder(WatermarkText);
}
$(".WatermarkPhoto").each(function(index) {
imgsrc = this.src;
var DataURL = imgsrc.replace('data:image/png;base64,', '');
ZipFolder.file(WatermarkText + index + ".png", DataURL, { base64: true });
});
zip.generateAsync({ type:"blob"})
.then(function (content) {
console.log(content);
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
savePicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
savePicker.fileTypeChoices.insert("ZIP archive", [".zip"]);
savePicker.suggestedFileName = WatermarkText+".zip";
savePicker.pickSaveFileAsync().then(function (file) {
if (file) {
Windows.Storage.CachedFileManager.deferUpdates(file);
Windows.Storage.FileIO.writeTextAsync(file, content).done(function() {
Windows.Storage.CachedFileManager.completeUpdatesAsync(file).done(function (updateStatus) {
if (updateStatus === Windows.Storage.Provider.FileUpdateStatus.complete) {
console.log("File " + file.name + " was saved.");
} else {
console.log("File " + file.name + " couldn't be saved.");
}
});
});
} else {
console.log("Operation cancelled.");
}
});
});
});
_「このzipファイルをユーザーのディスクに書き込むためにはどのような組み合わせが必要かわかりません」この要件は* 10のOSが使用されているコンピュータにのみ適用されますか? – guest271314
はい。これは、Windowsのアプリケーションストアに入ることを試みているWindows 10のアプリケーションです。 –