import org.springframework.http.HttpHeaders; //导入方法依赖的package包/类
/**
* Adds an object to a bucket accepting encryption headers.
*
* http://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPart.html
*
* @param bucketName the Bucket in which to store the file in.
* @param uploadId id of the upload. Has to match all other part's uploads.
* @param partNumber number of the part to upload.
* @param encryption Defines the encryption mode.
* @param kmsKeyId Defines the KMS key id.
* @param request {@link HttpServletRequest} of this request.
*
* @return the etag of the uploaded part.
*
* @throws IOException in case of an error.
*/
@RequestMapping(
value = "/{bucketName:.+}/**",
params = {"uploadId", "partNumber"},
headers = {
NOT_COPY_SOURCE,
NOT_COPY_SOURCE_RANGE,
SERVER_SIDE_ENCRYPTION
},
method = RequestMethod.PUT)
public ResponseEntity putObjectPart(@PathVariable final String bucketName,
@RequestParam final String uploadId,
@RequestParam final String partNumber,
@RequestHeader(value = SERVER_SIDE_ENCRYPTION) final String encryption,
@RequestHeader(
value = SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID,
required = false) final String kmsKeyId,
final HttpServletRequest request) throws IOException {
final String filename = filenameFrom(bucketName, request);
final String etag = fileStore.putPart(bucketName,
filename,
uploadId,
partNumber,
request.getInputStream(),
isV4SigningEnabled(request));
final HttpHeaders responseHeaders = new HttpHeaders();
final String quotedEtag = "\"" + etag + "\"";
responseHeaders.setETag(quotedEtag);
return new ResponseEntity<>(responseHeaders, HttpStatus.CREATED);
}