google-cloud-storage: GCP Client for Haskell

[ library, mit, unclassified, web ] [ Propose Tags ] [ Report a vulnerability ]

GCP Storage bucket client for Haskell.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 1.1.0.0
Change log CHANGELOG.md
Dependencies aeson (<3), base (>=4.7 && <5), bytestring (>=0.9.1.4), google-cloud-common (>=1.1.0.0 && <1.2.0.0), http-conduit, http-types, text (>=1.2 && <3) [details]
License MIT
Copyright 2025 tushar
Author tushar
Maintainer tusharadhatrao@gmail.com
Revised Revision 1 made by tusharad at 2025-09-11T14:35:07Z
Category Web
Home page https://github.com/tusharad/google-cloud-haskell#readme
Bug tracker https://github.com/tusharad/google-cloud-haskell/issues
Source repo head: git clone https://github.com/tusharad/google-cloud-haskell
Uploaded by tusharad at 2025-09-11T14:34:06Z
Distributions NixOS:0.1.0.0
Downloads 9 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for google-cloud-storage-1.1.0.0

[back to package description]

google-cloud-storage

Haskell idiomatic client for Google Cloud Platform Storage service.

Full docs are available at https://github.com/tusharad/google-cloud-haskell

Installation

  • Cabal: add to your .cabal
    • build-depends: google-cloud-storage == 1.1.0.0
  • Stack: add to your package.yaml
    • dependencies: - google-cloud-storage == 1.1.0.0

This package depends on google-cloud-common for authentication and HTTP helpers.

Authentication

Authentication is handled by google-cloud-common and follows this order:

  1. Use GOOGLE_APPLICATION_CREDENTIALS to load a Service Account JSON and exchange a signed JWT for an access token.
  2. Otherwise, use the Compute metadata server (suitable for GCE/GKE).

Examples

Minimal examples using Google.Cloud.Storage.Bucket:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Lazy.Char8 as BSL
import Google.Cloud.Storage.Bucket

-- List buckets in a project
listBucketsExample :: IO ()
listBucketsExample = do
  let projectId = "my-gcp-project"
  eRes <- listBuckets projectId
  case eRes of
    Left err -> putStrLn ("Error: " <> err)
    Right buckets -> print buckets

-- Create a bucket
createBucketExample :: IO ()
createBucketExample = do
  let newBucket = CreateBucketData
        { name = "my-unique-bucket-name"
        , location = Location "us-central1"
        , storageClass = STANDARD
        , projectId = "my-gcp-project"
        }
  eRes <- createBucket newBucket
  case eRes of
    Left err -> putStrLn ("Create error: " <> err)
    Right _  -> putStrLn "Bucket created"

-- Upload and download objects
objectOpsExample :: IO ()
objectOpsExample = do
  let bucket = "my-bucket"
      object = "my-object.txt"
  _ <- uploadObject bucket object (BSL.pack "Hello, world!")
  eBody <- downloadObject bucket object
  case eBody of
    Left err -> putStrLn ("Download error: " <> err)
    Right body -> BSL.putStrLn body

-- Copy and delete an object
copyDeleteExample :: IO ()
copyDeleteExample = do
  let req = CopyObjectRequest
        { sourceBucketName = "my-bucket"
        , sourceObjectName = "my-object.txt"
        , destinationBucketName = "another-bucket"
        , destinationObject = "copied-object.txt"
        }
  _ <- copyObject req
  _ <- deleteObject "my-bucket" "my-object.txt"
  pure ()

License

MIT © Contributors