Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Oct 28, 2024
1 parent 5110cf6 commit 1925d6c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions azure-blob-storage/azure-blob-storage.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ library
, unordered-containers
hs-source-dirs: src
default-language: Haskell2010

executable example
main-is: Main.hs
hs-source-dirs: example
ghc-options: -Wall
default-language: Haskell2010
build-depends:
base >= 4.7 && < 5
, directory
, azure-auth
, azure-blob-storage
23 changes: 23 additions & 0 deletions azure-blob-storage/example/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{-# LANGUAGE OverloadedStrings #-}

module Main where

import System.Directory (doesFileExist)

import Azure.Auth (defaultAzureCredential)
import Azure.Blob.GetBlob (GetBlob (..), getBlobObject)
import Azure.Blob.Types (AccountName (..), BlobName (..), ContainerName (..))
import Azure.Types (newEmptyToken)

main :: IO ()
main = do
tok <- newEmptyToken
cred <- defaultAzureCredential Nothing "https://storage.azure.com" tok
-- In order to run this, you need to replace @AccountName@, @ContainerName@ and @BlobName@
-- with appropriate values in your resource group. These are just dummy values.
let account = AccountName "OneRepublic"
container = ContainerName "Native"
blob = BlobName "counting_stars.jpeg"
getBlobPayload = GetBlob account container blob cred
getBlobObject getBlobPayload "/tmp/counting_stars.jpeg"
doesFileExist "/tmp/counting_stars.jpeg" >>= print

0 comments on commit 1925d6c

Please sign in to comment.