io.kestra.storage.gcs.GcsFileAttributes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of storage-gcs Show documentation
Show all versions of storage-gcs Show documentation
Google Cloud Storage storage plugin for Kestra
package io.kestra.storage.gcs;
import com.google.cloud.storage.BlobInfo;
import io.kestra.core.storages.FileAttributes;
import lombok.Builder;
import lombok.Value;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.util.Optional;
@Value
@Builder
public class GcsFileAttributes implements FileAttributes {
String fileName;
BlobInfo blobInfo;
boolean isDirectory;
@Override
public long getLastModifiedTime() {
return Optional.ofNullable(blobInfo.getUpdateTimeOffsetDateTime())
.map(OffsetDateTime::toInstant)
.map(Instant::toEpochMilli)
.orElse(0L);
}
@Override
public long getCreationTime() {
return Optional.ofNullable(blobInfo.getCreateTimeOffsetDateTime())
.map(OffsetDateTime::toInstant)
.map(Instant::toEpochMilli)
.orElse(0L);
}
@Override
public FileType getType() {
if (isDirectory || fileName.endsWith("/") || blobInfo.getContentType().equals("application/x-directory")) {
return FileType.Directory;
}
return FileType.File;
}
@Override
public long getSize() {
return blobInfo.getSize();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy