Closed fils closed 5 years ago
Hi Doug,
Not sure if I understood correctly your question, but let's try to answer in parts:
Keep the structure inside the zip package
I've just modified the zip example to have the data in a subdirectory. Then, running go run main.go
, I've got the zip with the following structure:
unzip -l package.zip
Archive: package.zip
Length Date Time Name
--------- ---------- ----- ----
548 2018-05-01 10:01 datapackage.json
183 2018-05-01 10:01 data/data.csv
--------- -------
731 2 files
Then I created a new directory, moved package.zip
there and unzipped. After that, the same structure was created.
Keep the structure outside the zip package
However, I am actually generating this in a directory called testproj2 ... Am I missing a way to generate the zip file such that when it unzips it unzips into a directory named testproj2 with the above structure inside it?
The packaging is completely agnostic regarding the directory structure outside it (including the CWD and so on). It only looks and tries to mimic resources paths. The root directory will be aways where the datapackage.json
lives.
If you want to keep everything self-contained within the package, you could solve this problem by adding a field to the descriptor to store the base directory of the datapackage.json
(it is totally fine to store metadata in the package descriptor). Then your program could load the package, read the metadata, create the directory and move the package before unzip.
Hi @fils , did that answer your question? Can I close this issue?
I need some help with creating zip files from the datapackage.json file.
I've been able to programmatically generate the datapackage.json and move files around so that I can then generate the zip files. However, all my files unzip into the CWD. That is there is no master, top level parent directory for the data package structure to end up in.
So I end up with something like
However, I am actually generating this in a directory called
testproj2
.Am I missing a way to generate the zip file such that when it unzips it unzips into a directory named testproj2 with the above structure inside it?
Thanks!