Skip to content

Commit 8119a0e

Browse files
committed
Added setProjectAvatar() (#284).
1 parent 4a7bb82 commit 8119a0e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,4 +2387,34 @@ public Project transferProject(Object projectIdOrPath, String namespace) throws
23872387
Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "transfer");
23882388
return (response.readEntity(Project.class));
23892389
}
2390+
2391+
/**
2392+
* Uploads and sets the project avatar for the specified project
2393+
*
2394+
* <pre><code>PUT /projects/:id/uploads</code></pre>
2395+
*
2396+
* @param projectIdOrPath projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
2397+
* @param avatarFile the File instance of the avatar file to upload
2398+
* @return the updated Project instance
2399+
* @throws GitLabApiException if any exception occurs
2400+
*/
2401+
public Project setProjectAvatar(Object projectIdOrPath, File fileToUpload) throws GitLabApiException {
2402+
return (setProjectAvatar(projectIdOrPath, fileToUpload, null));
2403+
}
2404+
2405+
/**
2406+
* Uploads and sets the project avatar for the specified project.
2407+
*
2408+
* <pre><code>PUT /projects/:id/uploads</code></pre>
2409+
*
2410+
* @param projectIdOrPath projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
2411+
* @param avatarFile the File instance of the avatar file to upload
2412+
* @param mediaType the media type of the avatar file to upload, optional
2413+
* @return the updated Project instance
2414+
* @throws GitLabApiException if any exception occurs
2415+
*/
2416+
public Project setProjectAvatar(Object projectIdOrPath, File avatarFile, String mediaType) throws GitLabApiException {
2417+
Response response = putUpload(Response.Status.OK, "avatar", avatarFile, mediaType, "projects", getProjectIdOrPath(projectIdOrPath));
2418+
return (response.readEntity(Project.class));
2419+
}
23902420
}

0 commit comments

Comments
 (0)