Packages

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
Linear Supertypes
Paging, FileIO, GcsDownloader, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GcsBucket
  2. Paging
  3. FileIO
  4. GcsDownloader
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def bucketInfo: GcsBucketInfo

    Returns the blob's GcsStorage object used to issue requests.

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. def createAcl(acl: Acl): Task[Acl]

    Creates a new ACL entry on this bucket.

  8. 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.

  9. def delete(options: BucketSourceOption*): Task[Boolean]

    Deletes this bucket.

  10. def deleteAcl(acl: Entity): Task[Boolean]

    Deletes the ACL entry for the specified entity on this bucket.

  11. def deleteDefaultAcl(acl: Entity): Task[Boolean]

    Deletes the default object ACL entry for the specified entity on this bucket.

  12. 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
    }
  13. 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
  14. 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.")
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def exists(options: BucketSourceOption*): Task[Boolean]

    Checks if this bucket exists.

  18. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  19. def getAcl(acl: Entity): Task[Option[Acl]]

    Returns the ACL entry for the specified entity on this bucket or None if not found.

  20. def getBlob(name: String, options: BlobGetOption*): Task[Option[GcsBlob]]

    Returns the requested blob in this bucket or None if it isn't found.

  21. 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.

  22. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. 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.

  24. def getStorage: GcsStorage

    Returns the blob's GcsStorage object used to issue requests.

  25. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  26. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  27. def listAcls(): Observable[Acl]

    Returns a Observable of all the ACL Entries for this GcsBucket.

  28. def listBlobs(options: BlobListOption*): Observable[GcsBlob]

    Returns a Observable of the blobs in this GcsBucket that matched with the passed BlobListOptions.

  29. def listDefaultAcls(): Observable[Acl]

    Returns a Observable of all the default Blob ACL Entries for this GcsBucket.

  30. def lockRetentionPolicy(options: BucketTargetOption*): Task[GcsBucket]

    Locks bucket retention policy.

    Locks bucket retention policy. Requires a local metageneration value in the request.

  31. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. def openFileInputStream(path: Path): Resource[Task, BufferedInputStream]
    Attributes
    protected
    Definition Classes
    FileIO
  35. def openFileOutputStream(path: Path): Observable[BufferedOutputStream]
    Attributes
    protected
    Definition Classes
    FileIO
  36. def reload(options: BucketSourceOption*): Task[Option[GcsBucket]]

    Reloads and refreshes this buckets data, returning a new Bucket instance.

  37. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  38. def toString(): String
    Definition Classes
    AnyRef → Any
  39. val underlying: Bucket
  40. 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.

  41. def updateAcl(acl: Acl): Task[Acl]

    Updates an ACL entry on this bucket.

  42. def updateDefaultAcl(acl: Acl): Task[Acl]

    Updates a default blob ACL entry on this bucket.

  43. 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)
  44. 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)
  45. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  46. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  48. def walk[A](f: Task[Page[A]]): Observable[A]
    Attributes
    protected
    Definition Classes
    Paging

Inherited from Paging

Inherited from FileIO

Inherited from GcsDownloader

Inherited from AnyRef

Inherited from Any

Ungrouped