当前位置: 首页>>代码示例>>Java>>正文


Java HttpHeaders.setLastModified方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:30,代码来源:FileStoreController.java

示例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);
  }
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:34,代码来源:FileStoreController.java

示例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);
  }
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:46,代码来源:FileStoreController.java


注:本文中的org.springframework.http.HttpHeaders.setLastModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。