Skip to content

Commit

Permalink
Merge pull request #8 from VEuPathDB/object-stream
Browse files Browse the repository at this point in the history
Implement object stream functionality
  • Loading branch information
dmgaldi authored Apr 18, 2023
2 parents 92bf234 + deb73ad commit e12ade7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "org.veupathdb.lib.s3"
version = "0.4.1+s34k-0.8.0"
version = "0.5.0+s34k-0.9.0"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -39,7 +39,7 @@ dependencies {
implementation("io.minio:minio:8.4.5")

@Suppress("GradlePackageVersionRange")
api("org.veupathdb.lib.s3:s34k-core:0.7.0+s34k-0.8.0")
api("org.veupathdb.lib.s3:s34k-core:0.8.0+s34k-0.9.0-SNAPSHOT")

testImplementation(kotlin("test"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.veupathdb.lib.s3.s34k.*
import org.veupathdb.lib.s3.s34k.buckets.S3Bucket
import org.veupathdb.lib.s3.s34k.core.objects.AbstractObjectContainer
import org.veupathdb.lib.s3.s34k.core.objects.BasicObjectList
import org.veupathdb.lib.s3.s34k.core.objects.BasicObjectStream
import org.veupathdb.lib.s3.s34k.core.objects.BasicSubPathListing
import org.veupathdb.lib.s3.s34k.errors.MultiObjectDeleteError
import org.veupathdb.lib.s3.s34k.errors.ObjectDeleteError
Expand Down Expand Up @@ -424,6 +425,53 @@ internal class BucketObjectContainer(
return StatObject(bucket, path, params, minio)
}

override fun stream(params: ObjectStreamParams): ObjectStream {
return BasicObjectStream(
minio.listObjects(ListObjectsArgs.builder()
.bucket(bucket)
.prefix(params.prefix)
.region(params, bucket)
.recursive(true)
.headers(params.headers)
.queryParams(params.queryParams)
.build())
.toStream()
.map(Result<Item>::get)
.map { MObject(
it.objectName(),
it.lastModified().toOffsetDateTime(),
it.etag(),
bucket.region,
MHeaders(),
bucket,
minio
) }
)
}

override fun streamAll(params: ObjectStreamAllParams): ObjectStream {
return BasicObjectStream(
minio.listObjects(ListObjectsArgs.builder()
.bucket(bucket)
.region(params, bucket)
.recursive(true)
.headers(params.headers)
.queryParams(params.queryParams)
.build())
.toStream()
.map(Result<Item>::get)
.map { MObject(
it.objectName(),
it.lastModified().toOffsetDateTime(),
it.etag(),
bucket.region,
MHeaders(),
bucket,
minio
) }
)
}

override fun touch(path: String, params: ObjectTouchParams): S3Object {
log.debug("Attempting to touch object '{}' in {}", path, bucket)
return ObjectToucher(bucket, path, params, minio).execute()
Expand Down

0 comments on commit e12ade7

Please sign in to comment.