1
votes

I have a Gradle build which is publishing a zip archive to Artifactory. Some downstream use cases require a single file from the zip artifact, so downloading the entire archive is inefficient. Is it possible to download a single file from within the zip archive?

I suspect an issue in the way the archive is being created. I cannot expand the zip contents through the web viewer, if that is a clue.

Here is the Gradle code used to create the zip artifact:

task buildZip(type: Zip) {
    description 'Create the ZIP file'
    classifier = System.env.CLASSIFIER
    extension = 'zip'
    def archive_loc = System.env.FOLDER_TO_ZIP
    from archive_loc
}
1
Artifactory's main access is via HTTP. While is is technically possible to request the ZIP "directory" to locate where exactly within that large ZIP file your single target file is, this is certainly inefficient. That would required many small HTTP calls for subsections of the file. Not recommended. Rather, you want to create two artefacts, one large one and one small one. You can use digests in the file name to make it clear which pairs belong together. - mgaert

1 Answers

6
votes

Artifactory allows downloading a specific file from an archive (Zip, Jar, War etc.) using the following notation:

http://localhost:8081/artifactory/repo-name/path/to/archive.zip!/path/to/file

For more details see the documentation for the Archive Entry Download REST API method