Skip to content

Commit cf7a81f

Browse files
mpkorstanjegmessner
authored andcommitted
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.
1 parent d53f2d3 commit cf7a81f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/org/gitlab4j/api/JobApi.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.io.InputStream;
66
import java.nio.file.Files;
7+
import java.nio.file.Path;
78
import java.nio.file.StandardCopyOption;
89
import java.util.List;
910
import java.util.Optional;
@@ -209,6 +210,25 @@ public InputStream downloadArtifactsFile(Integer projectId, String ref, String j
209210
return (response.readEntity(InputStream.class));
210211
}
211212

213+
/**
214+
* Download a single artifact file from within the job's artifacts archive.
215+
*
216+
* Only a single file is going to be extracted from the archive and streamed to a client.
217+
*
218+
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
219+
*
220+
* @param projectId The ID of the project owned by the authenticated user
221+
* @param jobId The unique job identifier
222+
* @param artifactPath Path to a file inside the artifacts archive
223+
* @return an InputStream to read the specified artifacts file from
224+
* @throws GitLabApiException if any exception occurs
225+
*/
226+
227+
public InputStream downloadSingleArtifactsFile(Integer projectId, Integer jobId, Path artifactPath) throws GitLabApiException {
228+
Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", projectId, "jobs", jobId, "artifacts", artifactPath);
229+
return (response.readEntity(InputStream.class));
230+
}
231+
212232
/**
213233
* Get a trace of a specific job of a project
214234
*

0 commit comments

Comments
 (0)