Commit cf7a81f1 authored by M.P. Korstanje's avatar M.P. Korstanje Committed by Greg Messner
Browse files

Add download a single artifact file endpoint (#209)

Download a single artifact file from within the job's artifacts archive.
Only a single file is going to be extracted from the archive and streamed to a client.
parent d53f2d32
...@@ -4,6 +4,7 @@ import java.io.File; ...@@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -209,6 +210,25 @@ public class JobApi extends AbstractApi implements Constants { ...@@ -209,6 +210,25 @@ public class JobApi extends AbstractApi implements Constants {
return (response.readEntity(InputStream.class)); return (response.readEntity(InputStream.class));
} }
/**
* Download a single artifact file from within the job's artifacts archive.
*
* Only a single file is going to be extracted from the archive and streamed to a client.
*
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
*
* @param projectId The ID of the project owned by the authenticated user
* @param jobId The unique job identifier
* @param artifactPath Path to a file inside the artifacts archive
* @return an InputStream to read the specified artifacts file from
* @throws GitLabApiException if any exception occurs
*/
public InputStream downloadSingleArtifactsFile(Integer projectId, Integer jobId, Path artifactPath) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "jobs", jobId, "artifacts", artifactPath);
return (response.readEntity(InputStream.class));
}
/** /**
* Get a trace of a specific job of a project * Get a trace of a specific job of a project
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment