I am trying to upload a CSV file into google cloud storage using CloseableHttpClient.getting response as 200 but content type is not properly reflected.
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response;
try {
ContentBody fileBody = new FileBody(content, ContentType.DEFAULT_BINARY);
HttpEntity entity = MultipartEntityBuilder.create().addPart("FILE_NAME", fileBody)
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE).build();
HttpPost request = new HttpPost(
"https://www.googleapis.com/upload/storage/v1/b/BUCKET_NAME/o?uploadType=media&name=FILE_NAME");
request.addHeader(Constants.API_HEADER_AUTHORIAZATION,
Constants.API_HEADER_AUTHORIAZATION_VALUE + accessToken());
request.setEntity(entity);
response = httpClient.execute(request);
Please find the below uploaded Google storage bucket Screenshot:
Content-Type
header as well ? – soufrk