Save stats request if lastmodify is set in header of write result in S3
This commit is contained in:
parent
98d22547b1
commit
d5598c3dd0
@ -243,14 +243,22 @@ class S3Impl {
|
|||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
PutObjectArgs putObjectArgs = PutObjectArgs.builder().bucket(cloud.s3Bucket()).object(file.getKey()).stream(out.open(context), data.size(context).get(), -1).build();
|
PutObjectArgs putObjectArgs = PutObjectArgs.builder().bucket(cloud.s3Bucket()).object(file.getKey()).stream(out.open(context), data.size(context).get(), -1).build();
|
||||||
client().putObject(putObjectArgs);
|
ObjectWriteResponse objectWriteResponse = client().putObject(putObjectArgs);
|
||||||
StatObjectResponse statObjectResponse = client().statObject(StatObjectArgs //
|
|
||||||
.builder() //
|
Date lastModified = objectWriteResponse.headers().getDate("Last-Modified");
|
||||||
.bucket(cloud.s3Bucket()) //
|
|
||||||
.object(file.getKey()) //
|
if(lastModified == null) {
|
||||||
.build());
|
StatObjectResponse statObjectResponse = client().statObject(StatObjectArgs //
|
||||||
|
.builder() //
|
||||||
|
.bucket(cloud.s3Bucket()) //
|
||||||
|
.object(file.getKey()) //
|
||||||
|
.build());
|
||||||
|
|
||||||
|
lastModified = Date.from(statObjectResponse.lastModified().toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
progressAware.onProgress(Progress.completed(UploadState.upload(file)));
|
progressAware.onProgress(Progress.completed(UploadState.upload(file)));
|
||||||
return S3CloudNodeFactory.file(file.getParent(), file.getName(), Optional.of(statObjectResponse.size()), Optional.of(Date.from(statObjectResponse.lastModified().toInstant())));
|
return S3CloudNodeFactory.file(file.getParent(), file.getName(), Optional.of(size), Optional.of(lastModified));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleApiError(ex, file.getPath());
|
handleApiError(ex, file.getPath());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user