由于要上传的文件很大,我正在分段上传到预签名的url。(2GB) 。要做的代码如下
docker commit
但这会将文件上传到存储桶。还要将以下数据附加到文件的开头。
public static Boolean upload(File file, String presignedUrl) {
try {
//Creating CloseableHttpClient object
CloseableHttpClient httpclient = HttpClients.createDefault();
//Creating the MultipartEntityBuilder
MultipartEntityBuilder entitybuilder = MultipartEntityBuilder.create();
//Setting the mode
entitybuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
//Adding a file
entitybuilder.addBinaryBody(file.getName(), file);
//Building a single entity using the parts
HttpEntity mutiPartHttpEntity = entitybuilder.build();
//Building the RequestBuilder request object
RequestBuilder reqbuilder = RequestBuilder.put(presignedUrl);
//Set the entity object to the RequestBuilder
reqbuilder.setEntity(mutiPartHttpEntity);
//Building the request
HttpUriRequest multipartRequest = reqbuilder.build();
//Executing the request
HttpResponse httpresponse = httpclient.execute(multipartRequest);
httpclient.close();
}catch (Exception e){
return false;
}
return true;
}
它也以
结尾--VqGPRk3XR7rn9v-Yqa0yWjVmyP^M
Content-Disposition: form-data; name="xxxx.csv"; filename="xxxx.csv"^M
Content-Type: application/octet-stream^M
Content-Transfer-Encoding: binary^M
^M
这是行为。但我也在寻找摆脱这种元数据的方法,因为这会阻碍csv处理。 请建议我在这里做错了什么,可以做些什么来避免这种情况。