diff --git a/azure-blob-storage/azure-blob-storage.cabal b/azure-blob-storage/azure-blob-storage.cabal index c9c64c7..ebb2608 100644 --- a/azure-blob-storage/azure-blob-storage.cabal +++ b/azure-blob-storage/azure-blob-storage.cabal @@ -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 diff --git a/azure-blob-storage/example/Main.hs b/azure-blob-storage/example/Main.hs new file mode 100644 index 0000000..ea2bc84 --- /dev/null +++ b/azure-blob-storage/example/Main.hs @@ -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