{"id":16726343,"url":"https://github.com/brunobonacci/clj4azure-storage","last_synced_at":"2025-07-25T09:44:28.087Z","repository":{"id":25703647,"uuid":"29140173","full_name":"BrunoBonacci/clj4azure-storage","owner":"BrunoBonacci","description":"A Clojure wrapper for Azure Storage SDK","archived":false,"fork":false,"pushed_at":"2015-02-14T19:52:50.000Z","size":142,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T05:28:32.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BrunoBonacci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-12T14:51:03.000Z","updated_at":"2021-08-13T04:53:07.000Z","dependencies_parsed_at":"2022-08-24T14:12:56.855Z","dependency_job_id":null,"html_url":"https://github.com/BrunoBonacci/clj4azure-storage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrunoBonacci%2Fclj4azure-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrunoBonacci%2Fclj4azure-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrunoBonacci%2Fclj4azure-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrunoBonacci%2Fclj4azure-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrunoBonacci","download_url":"https://codeload.github.com/BrunoBonacci/clj4azure-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243747732,"owners_count":20341554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T22:52:56.759Z","updated_at":"2025-03-15T15:24:50.600Z","avatar_url":"https://github.com/BrunoBonacci.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj4azure-storage\n\n`clj4azure-storage` is a Clojure wrapper for the Azure Storage SDK.\n\n`clj4azure-storage` repo available at: [https://github.com/BrunoBonacci/clj4azure-storage](https://github.com/BrunoBonacci/clj4azure-storage)\n\nAuthors:\n\n  - Bruno Bonacci\n  - Dayo Oliyide\n\n\n## Usage\n\nThis is still a work in progress, currently we support the following services/features\n\n  * Azure Storage\n    * Blobs\n      * Create container\n      * list blobs in a container\n      * download blobs from a container\n      * upload blobs(files) into containers\n\nTo use the library, add the following dependency to your `project.clj`\n\n    [clj4azure/clj4azure-storage \"0.1.0\"]\n\nand then in your namespace add:\n\n```Clojure\n\n(ns myproject\n    (:refer-clojure :exclude [list])\n    (:require [clj4azure.storage.blob :refer :all]))\n         \n```\n\n### Storage / blobs\n\n\nConnect to a container (either existing or create one if needed):\n\n```Clojure\n\n(def cnt (blob-container \n          {:storage-account-name \"my-account\"\n           :storage-account-key  \"my-account-key\"\n           :storage-container    \"my-container\"}))\n           \n(def new-cnt (blob-container \n              {:storage-account-name \"my-account\"\n               :storage-account-key  \"my-account-key\"\n               :storage-container    \"new-container\"\n               :create-if-needed true}))\n\n```\n\nList the content of a container.\n\n```Clojure\n\n(list cnt)\n;;=\u003e (\"file1.txt\" \"file2.txt\" \"directory1/\" ... ) \n\n```\n\nList all blobs which starts with a common prefix\n\n```Clojure\n\n(list cnt :prefix \"file\")\n;;=\u003e (\"file1.txt\" \"file2.txt\")\n\n```\n\nList the content of the sub-directories\n*NOTE: `list` is NOT lazy, so if you have large number of files might cause OutOfMemoryError.*\n\n```Clojure\n\n(list cnt :recursive true)\n;;=\u003e (\"file1.txt\" \n      \"file2.txt\" \n      \"directory1/\" \n      \"directory1/fileA.txt\" \n      \"directory1/fileB.txt\"\n      ... ) \n\n```\n\nOptionally you can get the full metadata associated with the blobs\n\n\n```Clojure\n\n(list cnt :recursive true :with-metadata true)\n\n;; =\u003e\n({:is-directory? false,\n  :path \"directory1/fileA.txt\",\n  :uri #\u003cURI https://my-account.blob.core.windows.net/my-container/directory1/fileA.txt\u003e,\n  :metadata {\"hdi_permission\" \n              \"{\\\"owner\\\":\\\"admin\\\",\\\"group\\\":\\\"supergroup\\\",\\\"permissions\\\":\\\"rwxr-xr-x\\\"}\" },\n  :properties {:content-language nil,\n               :content-disposition nil,\n               :lease-status :UNLOCKED,\n               :etag \"\\\"0x8D1C0AF11753D19\\\"\",\n               :last-modified #inst \"2014-10-28T10:14:18.000-00:00\",\n               :cache-control nil,\n               :lease-duration nil,\n               :length 544,\n               :content-type \"application/octet-stream\",\n               :content-md5 \"Qtg4wMzVyJnihlpd2P6Msw==\",\n               :copy-state nil,\n               :content-econding nil,\n               :lease-state :AVAILABLE,\n               :blob-type :BLOCK_BLOB}},\n   \n   ...)\n\n```\n\nFor example if you want to find last 10 files which have been created/modified \nin a specific container you can do as follow:\n\n```Clojure\n\n; download last 10 files\n(-\u003e\u003e\n (list cnt :recursive true  :with-metadata true)       ;; list blobs with metadata\n (filter (complement :is-directory?))                  ;; filter directories out\n (map (juxt :path (comp :last-modified :properties)))  ;; extract only :path and :last-modified\n (sort-by second)                                      ;; sort-by timestamp\n (map first)                                           ;; extract only path names \n (take-last 10))                                       ;; finally take the last 10\n\n;=\u003e (\"new-file1.txt\" \"/some-dir/new-file2.json\" ...)\n\n```\n\nYou can download a blob with the following function which takes\n\n  - a container\n  - a blob to download\n  - a local filename to write to\n  - optionally whether to overwrite the file if it exists locally (default: false) \n\n```Clojure\n\n(download-blob cnt \"my-data/history/buildings.csv\" \"/tmp/buildings.csv\" :overwrite true)\n;;=\u003e #\u003cFile \"/tmp/buildings.csv\"\u003e\n\n```\n\nIf you don't mind about the local filename you can just download to a temporary file with:\n\n```Clojure\n\n(download-blob-to-temp\n  cnt                              ;; a container\n  \"my-data/history/buildings.csv\"  ;; blob to download\n  \"/tmp\"                           ;; folder where to download to\n  :file-prefix \"XXXX\"              ;; generate temp files with the following prefix (default \"blob-\") \n  :file-suffix \"YYYY\")             ;; generate temp files with the following suffiz (default \".data\")\n\n\n```\n\nYou can upload a file into blob storage using the following function which takes\n\n  - a container\n  - a blob name\n  - a local filename to upload\n  \n```Clojure\n\n(upload-blob cnt \"Flats.csv\" \"/tmp/flats.csv\")\n\n```\n\n## License\n\nCopyright © 2014 B. Bonacci, D. Oliyide\n\nDistributed under the The MIT License (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobonacci%2Fclj4azure-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunobonacci%2Fclj4azure-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunobonacci%2Fclj4azure-storage/lists"}