{"id":19426610,"url":"https://github.com/oscaro/clj-gcloud-storage","last_synced_at":"2025-04-06T05:18:00.343Z","repository":{"id":34886938,"uuid":"183633785","full_name":"oscaro/clj-gcloud-storage","owner":"oscaro","description":"Clojure wrapper for google-cloud-storage Java client.","archived":false,"fork":false,"pushed_at":"2025-02-03T13:23:09.000Z","size":80,"stargazers_count":27,"open_issues_count":0,"forks_count":6,"subscribers_count":19,"default_branch":"devel","last_synced_at":"2025-03-30T04:10:05.635Z","etag":null,"topics":["clojure","google-cloud","google-cloud-storage"],"latest_commit_sha":null,"homepage":"https://cljdoc.org/d/com.oscaro/clj-gcloud-storage/0.112-1.0/doc/readme","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oscaro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-26T13:30:09.000Z","updated_at":"2025-02-10T01:45:13.000Z","dependencies_parsed_at":"2024-06-28T11:10:17.383Z","dependency_job_id":"83962894-151c-46b8-830c-7ed9274e9c29","html_url":"https://github.com/oscaro/clj-gcloud-storage","commit_stats":{"total_commits":71,"total_committers":7,"mean_commits":"10.142857142857142","dds":0.704225352112676,"last_synced_commit":"b6be38e7bcbe91b648965c08d4c8cadd74d1e140"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscaro%2Fclj-gcloud-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscaro%2Fclj-gcloud-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscaro%2Fclj-gcloud-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscaro%2Fclj-gcloud-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oscaro","download_url":"https://codeload.github.com/oscaro/clj-gcloud-storage/tar.gz/refs/heads/devel","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436359,"owners_count":20938546,"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":["clojure","google-cloud","google-cloud-storage"],"created_at":"2024-11-10T14:08:19.731Z","updated_at":"2025-04-06T05:18:00.259Z","avatar_url":"https://github.com/oscaro.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-gcloud-storage\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.oscaro/clj-gcloud-storage.svg)](https://clojars.org/com.oscaro/clj-gcloud-storage)\n\n[![cljdoc badge](https://cljdoc.org/badge/com.oscaro/clj-gcloud-storage)](https://cljdoc.org/d/com.oscaro/clj-gcloud-storage/CURRENT)\n\nClojure wrapper for [google-cloud-storage] Java client.\n\n## Usage\n\n```clojure\n[com.oscaro/clj-gcloud-storage \"0.215-1.0\"]\n```\n\n### Initializing a client\n\nAs any other Google cloud service, Storage requires the user to be authentified.\nThus, you must create a client you will then pass to every operation :\n\nThere are several ways to authenticate, two major ones :\n\n```clojure\n;; Local credentials, require them to have been created on your side\n;; Default project will be used\n(def client (st/init))\n;; or equivalent\n(def client (st/init {}))\n\n;; Service account usage for portable applications\n(def client\n  (st/init\n    {:project-id \"my-project\"\n     :credentials \"my-service-account.json\"}))\n```\n\n### Uploading and downloading files\n\nUploading and downloading files is one the most basic operation in Google Cloud Storage\nand one of the core need you expect from it in most cases.\nNote however that data can be streamed in a more sophisticated way from and to Storage blobs, however\nit requires more work on byte arrays.\n\n```clojure\n;; Let's download a file and upload it back\n\n;; Local credentials\n(def client (st/init {}))\n\n;; Actual (blocking) download\n;; The file will be downloaded on disk\n(download-file-from-storage storage-client \"gs://mybucket/myfolder/myotherfolder/myfile.ext\" \"mylocalfile.ext\")\n\n;; Now we upload a the file again to a copy location\n(copy-file-to-storage storage-client (io/file \"mylocalfile.ext\") \"gs://mybucket/myfolder/myotherfolder/myfilecopy.ext\")\n```\n\n### Objects creation, deletion and copy\n\nCommon operations you expect from a \"file-system\" are available.\nTwo main object types can be found in Google Storage : buckets which are \"folders\"\nat the root of the project and blobs which are everything else.\n\n#### Creation\n\n```clojure\n;; You can create a bucket this way\n;; See other options in code and documentation\n(create-bucket\n  client\n  (bucket-info\n    \"mybucket\"\n    {:location \"europe-west1\"}))\n\n;; Blobs are created similarly\n;; Subfolders under buckets (which must be constructed before)\n;; are created automatically\n;; Blob IDs can be inferred from a gs uri\n(create-blob\n  client\n  (blob-info\n    (-\u003eblob-id \"mybucket\" \"whatever/again/myfile.ext\")\n    {}))\n```\n\n#### Deletion\n\n```clojure\n;; Bucket deletion is straightforward\n(delete-bucket client \"mybucket\")\n\n;; Blobs require coercion to BlobId\n(delete-blob client (-\u003eblob-id \"gs://mybucket/whatever/again/myfile.ext\"))\n```\n\n#### Copy\n\n```clojure\n;; Buckets cannot be copied\n;; Blobs can\n;; Here is one method\n(copy client\n  (-\u003eblob-id \"gs://mybucket/whatever/again/myfile.ext\")\n  (-\u003eblob-id \"gs://mybucket/whatever/again-archive/myfile.ext\"))\n```\n\nYou can also get buckets or blobs to work directly on it.\nThis can be useful when you perform multiple operations\non the same blob.\n\n### Listing blobs\n\nYou can list blobs under a specific uri. You can then coerce back\nthe result to uris.\n\n```clojure\n;; Basic usage\n(ls client \"gs://mybucket/whatever/again/\")\n\n;; Full coercion to GS uris\n(-\u003e\u003e (ls client \"gs://mybucket/whatever/again/\")\n     (map\n       (fn [obj]\n         (let [{:keys [blob-id]} (clj-gcloud.coerce/-\u003eclj blob-id)]\n           (str \"gs://mybucket/\" (:name blob-id))))))\n```\n\n## License\n\nCopyright © 2017-2025 Oscaro\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n\n[google-cloud-storage]: https://github.com/googleapis/java-storage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscaro%2Fclj-gcloud-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foscaro%2Fclj-gcloud-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscaro%2Fclj-gcloud-storage/lists"}