{"id":19502323,"url":"https://github.com/zio/zio-s3","last_synced_at":"2025-04-06T20:13:01.907Z","repository":{"id":37629197,"uuid":"231638369","full_name":"zio/zio-s3","owner":"zio","description":"An S3 client for ZIO","archived":false,"fork":false,"pushed_at":"2024-10-10T18:47:40.000Z","size":1656,"stargazers_count":44,"open_issues_count":16,"forks_count":31,"subscribers_count":6,"default_branch":"series/2.x","last_synced_at":"2025-03-30T19:07:04.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://zio.dev/zio-s3/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zio.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-03T17:55:59.000Z","updated_at":"2025-03-18T17:31:02.000Z","dependencies_parsed_at":"2024-04-09T21:41:21.092Z","dependency_job_id":"64755c52-25db-4c31-a56e-66f768e33af4","html_url":"https://github.com/zio/zio-s3","commit_stats":{"total_commits":217,"total_committers":29,"mean_commits":7.482758620689655,"dds":0.5944700460829493,"last_synced_commit":"a8616ca946fd2d1b08a04221aa76f839a076f66b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-s3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-s3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-s3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Fzio-s3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zio","download_url":"https://codeload.github.com/zio/zio-s3/tar.gz/refs/heads/series/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543593,"owners_count":20955865,"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-11-10T22:16:05.165Z","updated_at":"2025-04-06T20:13:01.880Z","avatar_url":"https://github.com/zio.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)\n[//]: # (So please do not edit it manually. Instead, change \"docs/index.md\" file or sbt setting keys)\n[//]: # (e.g. \"readmeDocumentation\" and \"readmeSupport\".)\n\n# ZIO S3\n\n[ZIO S3](https://github.com/zio/zio-s3) is a thin wrapper over S3 async client for ZIO.\n\n[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/zio-s3/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-s3_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-s3_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-s3_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-s3_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-s3-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-s3-docs_2.13) [![ZIO S3](https://img.shields.io/github/stars/zio/zio-s3?style=social)](https://github.com/zio/zio-s3)\n\n## Introduction\n\nZIO-S3 is a thin wrapper over the s3 async java client. It exposes the main operations of the s3 java client.\n\n```scala\nimport software.amazon.awssdk.auth.credentials.AwsBasicCredentials\nimport zio.Chunk\nimport zio.s3._\nimport zio.stream.{ZSink, ZStream}\nimport software.amazon.awssdk.services.s3.model.S3Exception\n\n  // list all buckets available  \n  listBuckets.provideLayer(\n     live(\"us-east-1\", AwsBasicCredentials.create(\"accessKeyId\", \"secretAccessKey\"))\n  )\n  \n  // list all objects of all buckets\n  val l2: ZStream[S3, S3Exception, String] = (for {\n     bucket \u003c- ZStream.fromIterableZIO(listBuckets) \n     obj \u003c- listAllObjects(bucket.name)\n  } yield obj.bucketName + \"/\" + obj.key).provideLayer(\n     live(\"us-east-1\", AwsBasicCredentials.create(\"accessKeyId\", \"secretAccessKey\"))\n  )  \n```\n\nAll available s3 combinators and operations are available in the package object `zio.s3`, you only need to `import zio.s3._`\n\n## Installation\n\nIn order to use this library, we need to add the following line in our `build.sbt` file:\n\n```scala\nlibraryDependencies += \"dev.zio\" %% \"zio-s3\" % \"0.4.3\"\n```\n\n## Example 1\n\nLet's try an example of creating a bucket and adding an object into it. To run this example, we need to run an instance of _Minio_ which is object storage compatible with S3:\n\n```bash\ndocker run -p 9000:9000 -e MINIO_ROOT_USER=MyKey -e MINIO_ROOT_PASSWORD=MySecret minio/minio  server --compat /data\n```\n\nIn this example we create a bucket and then add a JSON object to it and then retrieve that:\n\n```scala\nimport software.amazon.awssdk.auth.credentials.AwsBasicCredentials\nimport software.amazon.awssdk.regions.Region\nimport zio._\nimport zio.s3._\nimport zio.stream.{ZStream, ZPipeline}\nimport zio.Chunk\n\nimport java.net.URI\n\nobject ZIOS3Example extends ZIOAppDefault {\n\n  val myApp = for {\n    _ \u003c- createBucket(\"docs\")\n    json = Chunk.fromArray(\"\"\"{  \"id\" : 1 , \"name\" : \"A1\" }\"\"\".getBytes)\n    _ \u003c- putObject(\n      bucketName = \"docs\",\n      key = \"doc1\",\n      contentLength = json.length.toLong,\n      content = ZStream.fromChunk(json),\n      options = UploadOptions.fromContentType(\"application/json\")\n    )\n    _ \u003c- getObject(\"docs\", \"doc1\")\n      .via(ZPipeline.utf8Decode)\n      .foreach(Console.printLine(_))\n  } yield ()\n\n  def run =\n    myApp\n      .provide(\n        live(\n          Region.CA_CENTRAL_1,\n          AwsBasicCredentials.create(\"MyKey\", \"MySecret\"),\n          Some(URI.create(\"http://localhost:9000\")),\n          forcePathStyle = Some(true) // Required for path-style S3 requests (MinIO by default uses them)\n        )\n      )\n}\n```\n\n## Example 2\n\n```scala\nimport software.amazon.awssdk.services.s3.model.S3Exception\nimport zio._\nimport zio.stream.{ ZSink, ZStream }\nimport zio.s3._\n\n// upload\nval json: Chunk[Byte] = Chunk.fromArray(\"\"\"{  \"id\" : 1 , \"name\" : \"A1\" }\"\"\".getBytes)\nval up: ZIO[S3, S3Exception, Unit] = putObject(\n  \"bucket-1\",\n  \"user.json\",\n  json.length.toLong,\n  ZStream.fromChunk(json),\n  UploadOptions.fromContentType(\"application/json\")\n)\n\n// multipartUpload \nimport java.io.FileInputStream\nimport java.nio.file.Paths\n\nval is = ZStream.fromInputStream(new FileInputStream(Paths.get(\"/my/path/to/myfile.zip\").toFile))\nval proc2: ZIO[S3, S3Exception, Unit] =\n  multipartUpload(\n    \"bucket-1\",\n    \"upload/myfile.zip\",\n    is,\n    MultipartUploadOptions.fromUploadOptions(UploadOptions.fromContentType(\"application/zip\"))\n  )(4)\n\n// download\nimport java.io.OutputStream\n\nval os: OutputStream = ???\nval proc3: ZIO[S3, Exception, Long] = getObject(\"bucket-1\", \"upload/myfile.zip\").run(ZSink.fromOutputStream(os))\n```\n\n## Support any commands?\n\nIf you need a method which is not wrapped by the library, you can have access to underlying S3 client in a safe manner by using\n\n```scala\nimport java.util.concurrent.CompletableFuture\nimport zio.s3._\nimport software.amazon.awssdk.services.s3.S3AsyncClient\n \ndef execute[T](f: S3AsyncClient =\u003e CompletableFuture[T]) \n```\n\n## Documentation\n\nLearn more on the [ZIO S3 homepage](https://zio.dev/zio-s3/)!\n\n## Contributing\n\nFor the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing).\n\n## Code of Conduct\n\nSee the [Code of Conduct](https://zio.dev/about/code-of-conduct)\n\n## Support\n\nCome chat with us on [![Badge-Discord]][Link-Discord].\n\n[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord \"chat on discord\"\n[Link-Discord]: https://discord.gg/2ccFBr4 \"Discord\"\n\n## License\n\n[License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio%2Fzio-s3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzio%2Fzio-s3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio%2Fzio-s3/lists"}