From 1925d6cf9d68669f4eb8a4cef887167c81a01dfc Mon Sep 17 00:00:00 2001 From: Nitin Prakash Date: Mon, 28 Oct 2024 23:16:00 +0530 Subject: [PATCH] example --- azure-blob-storage/azure-blob-storage.cabal | 11 ++++++++++ azure-blob-storage/example/Main.hs | 23 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 azure-blob-storage/example/Main.hs 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