class GcsBucket extends GcsDownloader with FileIO with Paging
This class wraps the com.google.cloud.storage.Bucket class, providing an idiomatic scala API handling null values with Option where applicable, as well as wrapping all side-effectful calls in monix.eval.Task or monix.reactive.Observable.
- Self Type
- GcsBucket
- Source
- GcsBucket.scala
- Alphabetic
- By Inheritance
- GcsBucket
- Paging
- FileIO
- GcsDownloader
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bucketInfo: GcsBucketInfo
Returns the blob's GcsStorage object used to issue requests.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def createAcl(acl: Acl): Task[Acl]
Creates a new ACL entry on this bucket.
- def createDefaultAcl(acl: Acl): Task[Acl]
Creates a new default blob ACL entry on this bucket.
Creates a new default blob ACL entry on this bucket. Default ACLs are applied to a new blob within the bucket when no ACL was provided for that blob.
- def delete(options: BucketSourceOption*): Task[Boolean]
Deletes this bucket.
- def deleteAcl(acl: Entity): Task[Boolean]
Deletes the ACL entry for the specified entity on this bucket.
- def deleteDefaultAcl(acl: Entity): Task[Boolean]
Deletes the default object ACL entry for the specified entity on this bucket.
- def download(blobName: String, chunkSize: Int = 4096): Observable[Array[Byte]]
Downloads a Blob from GCS, returning an Observable containing the bytes in chunks of length chunkSize.
Downloads a Blob from GCS, returning an Observable containing the bytes in chunks of length chunkSize.
Example
import monix.connect.gcp.storage.configuration.GcsBucketInfo.Locations import monix.connect.gcp.storage.{GcsBucket, GcsStorage} import monix.eval.Task import monix.reactive.Observable val storage = GcsStorage.create() val memoizedBucket: Task[GcsBucket] = storage.createBucket("myBucket", Locations.`EUROPE-WEST3`).memoize val ob: Observable[Array[Byte]] = { for { bucket <- Observable.fromTask(memoizedBucket) content <- bucket.download("myBlob") } yield content }
- def download(storage: Storage, blobId: BlobId, chunkSize: Int): Observable[Array[Byte]]
Downloads the content from a Blob in form an array byte Observable of the specified chunksize.
Downloads the content from a Blob in form an array byte Observable of the specified chunksize.
- storage
underlying Storage instance.
- blobId
the source blob id to download from.
- chunkSize
conforms the size in bytes of each future read element.
- returns
an array bytes Observable.
- Attributes
- protected
- Definition Classes
- GcsDownloader
- def downloadToFile(blobName: String, path: Path, chunkSize: Int = 4096): Task[Unit]
Downloads a Blob from GCS directly to the specified file.
Downloads a Blob from GCS directly to the specified file.
Example
import java.io.File import monix.connect.gcp.storage.GcsStorage import monix.eval.Task val storage = GcsStorage.create() val targetFile = new File("example/target/file.txt") val t: Task[Unit] = { for { maybeBucket <- storage.getBucket("myBucket") _ <- maybeBucket match { case Some(bucket) => bucket.downloadToFile("myBlob", targetFile.toPath) case None => Task.unit // alternatively a failure can be raised } } yield () }
- Annotations
- @Unsafe("Risk of downloading large amounts of data into the local filesystem.")
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exists(options: BucketSourceOption*): Task[Boolean]
Checks if this bucket exists.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def getAcl(acl: Entity): Task[Option[Acl]]
Returns the ACL entry for the specified entity on this bucket or None if not found.
- def getBlob(name: String, options: BlobGetOption*): Task[Option[GcsBlob]]
Returns the requested blob in this bucket or None if it isn't found.
- def getBlobs(names: NonEmptyList[String]): Observable[GcsBlob]
Returns an Observable of the requested blobs, if one doesn't exist null is returned and filtered out of the result set.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getDefaultAcl(acl: Entity): Task[Option[Acl]]
Returns the default object ACL entry for the specified entity on this bucket or None if not found.
- def getStorage: GcsStorage
Returns the blob's GcsStorage object used to issue requests.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def listAcls(): Observable[Acl]
Returns a Observable of all the ACL Entries for this GcsBucket.
- def listBlobs(options: BlobListOption*): Observable[GcsBlob]
Returns a Observable of the blobs in this GcsBucket that matched with the passed BlobListOptions.
- def listDefaultAcls(): Observable[Acl]
Returns a Observable of all the default Blob ACL Entries for this GcsBucket.
- def lockRetentionPolicy(options: BucketTargetOption*): Task[GcsBucket]
Locks bucket retention policy.
Locks bucket retention policy. Requires a local metageneration value in the request.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def openFileInputStream(path: Path): Resource[Task, BufferedInputStream]
- Attributes
- protected
- Definition Classes
- FileIO
- def openFileOutputStream(path: Path): Observable[BufferedOutputStream]
- Attributes
- protected
- Definition Classes
- FileIO
- def reload(options: BucketSourceOption*): Task[Option[GcsBucket]]
Reloads and refreshes this buckets data, returning a new Bucket instance.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- val underlying: Bucket
- def update(options: BucketTargetOption*): Task[GcsBucket]
Updates this bucket with the provided options, returning the newly updated Bucket instance.
Updates this bucket with the provided options, returning the newly updated Bucket instance.
By default no checks are made on the metadata generation of the current bucket. If you want to update the information only if the current bucket metadata are at their latest version use the BucketTargetOption.metagenerationMatch option.
- def updateAcl(acl: Acl): Task[Acl]
Updates an ACL entry on this bucket.
- def updateDefaultAcl(acl: Acl): Task[Acl]
Updates a default blob ACL entry on this bucket.
- def upload(name: String, metadata: Option[Metadata] = None, chunkSize: Int = 4096, options: List[BlobWriteOption] = List.empty[BlobWriteOption]): GcsUploader
Provides a pre-built monix.reactive.Consumer that expects array bytes and uploads them all to this Blob.
Provides a pre-built monix.reactive.Consumer that expects array bytes and uploads them all to this Blob.
Example
import monix.execution.Scheduler.Implicits.global import monix.connect.gcp.storage.GcsStorage import monix.connect.gcp.storage.configuration.GcsBucketInfo import monix.eval.Task import monix.reactive.Observable val storage = GcsStorage.create() val memoizedBucket = storage.createBucket("myBucket", GcsBucketInfo.Locations.`EUROPE-WEST1`).memoize val ob: Observable[Array[Byte]] = Observable.now("dummy content".getBytes) val t: Task[Unit] = for { bucket <- memoizedBucket _ <- ob.consumeWith(bucket.upload("myBlob")) } yield () t.runToFuture(global)
- def uploadFromFile(blobName: String, path: Path, metadata: Option[Metadata] = None, chunkSize: Int = 4096, options: List[BlobWriteOption] = List.empty[BlobWriteOption]): Task[Unit]
Uploads the provided file to the specified target Blob.
Uploads the provided file to the specified target Blob.
Example
import java.io.File import monix.execution.Scheduler.Implicits.global import monix.connect.gcp.storage.GcsStorage import monix.connect.gcp.storage.configuration.GcsBucketInfo import monix.eval.Task val storage = GcsStorage.create() val sourceFile = new File("example/source/file.txt") val t: Task[Unit] = for { bucket <- storage.createBucket("myBucket", GcsBucketInfo.Locations.`US-WEST1`) unit <- bucket.uploadFromFile("myBlob", sourceFile.toPath) } yield () t.runToFuture(global)
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def walk[A](f: Task[Page[A]]): Observable[A]
- Attributes
- protected
- Definition Classes
- Paging