本文整理匯總了Java中org.springframework.http.HttpHeaders.setLastModified方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.setLastModified方法的具體用法?Java HttpHeaders.setLastModified怎麽用?Java HttpHeaders.setLastModified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.setLastModified方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putObject
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
/**
* Adds an object to a bucket.
*
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html
*
* @param bucketName the Bucket in which to store the file in.
* @param request http servlet request
* @return ResponseEntity with Status Code and ETag
*/
@RequestMapping(value = "/{bucketName:.+}/**", method = RequestMethod.PUT)
public ResponseEntity<String> putObject(@PathVariable final String bucketName,
final HttpServletRequest request) {
final String filename = filenameFrom(bucketName, request);
try (ServletInputStream inputStream = request.getInputStream()) {
final S3Object s3Object = fileStore.putS3Object(bucketName,
filename,
request.getContentType(),
inputStream,
isV4SigningEnabled(request));
final HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setETag("\"" + s3Object.getMd5() + "\"");
responseHeaders.setLastModified(s3Object.getLastModified());
return new ResponseEntity<>(responseHeaders, HttpStatus.CREATED);
} catch (final IOException e) {
LOG.error("Object could not be saved!", e);
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
示例2: headObject
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
/**
* Retrieves metadata from an object without returning the object itself.
*
* @param bucketName name of the bucket to look in
* @return ResponseEntity containing metadata and status
*/
@RequestMapping(
value = "/{bucketName:.+}/**",
method = RequestMethod.HEAD)
public ResponseEntity<String> headObject(@PathVariable final String bucketName,
final HttpServletRequest request) {
final String filename = filenameFrom(bucketName, request);
final S3Object s3Object = fileStore.getS3Object(bucketName, filename);
if (s3Object != null) {
final HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(Long.valueOf(s3Object.getSize()));
if (!"".equals(s3Object.getContentType())) {
responseHeaders.setContentType(MediaType.parseMediaType(s3Object.getContentType()));
}
responseHeaders.setETag("\"" + s3Object.getMd5() + "\"");
responseHeaders.setLastModified(s3Object.getLastModified());
if (s3Object.isEncrypted()) {
responseHeaders.add(SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID,
s3Object.getKmsKeyId());
}
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
示例3: putObjectEncrypted
import org.springframework.http.HttpHeaders; //導入方法依賴的package包/類
/**
* Adds an encrypted object to a bucket.
*
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html
*
* @param bucketName the Bucket in which to store the file in.
* @param encryption The encryption type.
* @param kmsKeyId The KMS encryption key id.
* @param request http servlet request.
*
* @return {@link ResponseEntity} with Status Code and empty ETag.
*
* @throws IOException in case of an error on storing the object.
*/
@RequestMapping(
value = "/{bucketName:.+}/**",
headers = {
SERVER_SIDE_ENCRYPTION,
SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID
},
method = RequestMethod.PUT)
public ResponseEntity<String> putObjectEncrypted(@PathVariable final String bucketName,
@RequestHeader(value = SERVER_SIDE_ENCRYPTION) final String encryption,
@RequestHeader(value = SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID) final String kmsKeyId,
final HttpServletRequest request) throws IOException {
final String filename = filenameFrom(bucketName, request);
final S3Object s3Object;
try (ServletInputStream inputStream = request.getInputStream()) {
s3Object =
fileStore.putS3ObjectWithKMSEncryption(bucketName,
filename,
request.getContentType(),
inputStream,
isV4SigningEnabled(request),
encryption,
kmsKeyId);
final HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setETag("\"" + s3Object.getMd5() + "\"");
responseHeaders.setLastModified(s3Object.getLastModified());
responseHeaders.add(SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID, kmsKeyId);
return new ResponseEntity<>(responseHeaders, HttpStatus.CREATED);
}
}