Commit 1a1c3b21 authored by Alberto Scotto's avatar Alberto Scotto
Browse files

Fixes as per review comments

parent 115a6a8b
...@@ -370,7 +370,7 @@ public abstract class AbstractApi implements Constants { ...@@ -370,7 +370,7 @@ public abstract class AbstractApi implements Constants {
* @param expectedStatus the HTTP status that should be returned from the server * @param expectedStatus the HTTP status that should be returned from the server
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaType the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaType unused; will be removed in the next major version
* @param pathArgs variable list of arguments used to build the URI * @param pathArgs variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException if any exception occurs during execution * @throws GitLabApiException if any exception occurs during execution
...@@ -398,7 +398,7 @@ public abstract class AbstractApi implements Constants { ...@@ -398,7 +398,7 @@ public abstract class AbstractApi implements Constants {
* @param expectedStatus the HTTP status that should be returned from the server * @param expectedStatus the HTTP status that should be returned from the server
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaType the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaType unused; will be removed in the next major version
* @param url the fully formed path to the GitLab API endpoint * @param url the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException if any exception occurs during execution * @throws GitLabApiException if any exception occurs during execution
...@@ -418,7 +418,7 @@ public abstract class AbstractApi implements Constants { ...@@ -418,7 +418,7 @@ public abstract class AbstractApi implements Constants {
* @param expectedStatus the HTTP status that should be returned from the server * @param expectedStatus the HTTP status that should be returned from the server
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaType the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaType unused; will be removed in the next major version
* @param formData the Form containing the name/value pairs * @param formData the Form containing the name/value pairs
* @param url the fully formed path to the GitLab API endpoint * @param url the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
......
...@@ -561,7 +561,7 @@ public class GitLabApiClient implements AutoCloseable { ...@@ -561,7 +561,7 @@ public class GitLabApiClient implements AutoCloseable {
* *
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaTypeString the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaTypeString unused; will be removed in the next major version
* @param pathArgs variable list of arguments used to build the URI * @param pathArgs variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws IOException if an error occurs while constructing the URL * @throws IOException if an error occurs while constructing the URL
...@@ -576,7 +576,7 @@ public class GitLabApiClient implements AutoCloseable { ...@@ -576,7 +576,7 @@ public class GitLabApiClient implements AutoCloseable {
* *
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaTypeString the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaTypeString unused; will be removed in the next major version
* @param formData the Form containing the name/value pairs * @param formData the Form containing the name/value pairs
* @param pathArgs variable list of arguments used to build the URI * @param pathArgs variable list of arguments used to build the URI
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
...@@ -593,17 +593,14 @@ public class GitLabApiClient implements AutoCloseable { ...@@ -593,17 +593,14 @@ public class GitLabApiClient implements AutoCloseable {
* *
* @param name the name for the form field that contains the file name * @param name the name for the form field that contains the file name
* @param fileToUpload a File instance pointing to the file to upload * @param fileToUpload a File instance pointing to the file to upload
* @param mediaTypeString the content-type of the uploaded file, if null will be determined from fileToUpload * @param mediaTypeString unused; will be removed in the next major version
* @param formData the Form containing the name/value pairs * @param formData the Form containing the name/value pairs
* @param url the fully formed path to the GitLab API endpoint * @param url the fully formed path to the GitLab API endpoint
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws IOException if an error occurs while constructing the URL * @throws IOException if an error occurs while constructing the URL
*/ */
protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, URL url) throws IOException { protected Response upload(String name, File fileToUpload, String mediaTypeString, Form formData, URL url) throws IOException {
MediaType mediaType = (mediaTypeString != null ? MediaType.valueOf(mediaTypeString) : null); FileDataBodyPart filePart = new FileDataBodyPart(name, fileToUpload);
FileDataBodyPart filePart = mediaType != null ?
new FileDataBodyPart(name, fileToUpload, mediaType) :
new FileDataBodyPart(name, fileToUpload);
return upload(filePart, formData, url); return upload(filePart, formData, url);
} }
...@@ -613,10 +610,7 @@ public class GitLabApiClient implements AutoCloseable { ...@@ -613,10 +610,7 @@ public class GitLabApiClient implements AutoCloseable {
} }
protected Response upload(String name, InputStream inputStream, String filename, String mediaTypeString, Form formData, URL url) throws IOException { protected Response upload(String name, InputStream inputStream, String filename, String mediaTypeString, Form formData, URL url) throws IOException {
MediaType mediaType = (mediaTypeString != null ? MediaType.valueOf(mediaTypeString) : null); StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart(name, inputStream, filename);
StreamDataBodyPart streamDataBodyPart = mediaType != null ?
new StreamDataBodyPart(name, inputStream, filename, mediaType) :
new StreamDataBodyPart(name, inputStream, filename);
return upload(streamDataBodyPart, formData, url); return upload(streamDataBodyPart, formData, url);
} }
......
...@@ -2552,7 +2552,7 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -2552,7 +2552,7 @@ public class ProjectApi extends AbstractApi implements Constants {
* *
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param fileToUpload the File instance of the file to upload, required * @param fileToUpload the File instance of the file to upload, required
* @param mediaType the media type of the file to upload, optional * @param mediaType unused; will be removed in the next major version
* @return a FileUpload instance with information on the just uploaded file * @return a FileUpload instance with information on the just uploaded file
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
...@@ -2569,7 +2569,6 @@ public class ProjectApi extends AbstractApi implements Constants { ...@@ -2569,7 +2569,6 @@ public class ProjectApi extends AbstractApi implements Constants {
* *
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param inputStream the data to upload, required * @param inputStream the data to upload, required
* @param mediaType the media type of the file to upload, required
* @return a FileUpload instance with information on the just uploaded file * @return a FileUpload instance with information on the just uploaded file
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
......
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