Is there a way to default or suggest a folder structure on a direct download without using a zip file?

99封情书 提交于 2019-12-13 02:58:26

问题


Q: Is there a way to default or suggest a folder structure on a direct download without using a zip file?

I have an AngularJS app that I use to generate text files that are imported into a commercial machine. In order for the import to work, the file has to be embedded in a particular folder structure. Is there a way to suggest this folder structure via the download dialog without having to use a zip file?

We use a zip today, but Windows users are having problems with the extracts working on the machine (see this question). Curious if there was a way to bypass the zip altogether.

Relevant info:

  • Angular version: 5.2.10
  • Zip Utility in angular: JSZip 3.1.5

JSZip code:

const zip = new JSZip();
zip.folder('FolderA/FolderB/FolderC').file('FILE.TXT', new File([contentString], 'TEMP.TXT', { type: 'text/plain' }));
zip.generateAsync({ type: 'blob' })
  .then(function (content) {
    saveAs(content, 'ZipFile.ZIP');
  });

回答1:


You could use tar instead of zip.

https://github.com/beatgammit/tar-js

But no, you you can't download a directory unless it's somehow converted to a single file.



来源:https://stackoverflow.com/questions/51315153/is-there-a-way-to-default-or-suggest-a-folder-structure-on-a-direct-download-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!