awscr-s3
Version, currently 0.3.09 versions
github.com/repomaa/awscr-s3
A Crystal shard for S3.
Nothing has been indexed for 0.3.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
awscr-s3:
github: repomaa/awscr-s3
version: ~> 0.3.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.3.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
awscr-s3
A Crystal shard for S3 and compatible services.
Installation
Add this to your application's shard.yml:
dependencies:
awscr-s3:
github: taylorfinnell/awscr-s3
Examples
Documentation
Usage
require "awscr-s3"
Creating a Client
client = Awscr::S3::Client.new("us-east1", "key", "secret")
For S3 compatible services, like DigitalOcean Spaces or Minio, you'll need to set a custom endpoint:
client = Awscr::S3::Client.new("nyc3", "key", "secret", endpoint: "https://nyc3.digitaloceanspaces.com")
If you wish you wish to you version 2 request signing you may specify the signer
client = Awscr::S3::Client.new("us-east1", "key", "secret", signer: :v2)
List Buckets
resp = client.list_buckets
resp.buckets # => ["bucket1", "bucket2"]
Delete a bucket
client = Client.new("region", "key", "secret")
resp = client.delete_bucket("test")
resp # => true
Create a bucket
client = Client.new("region", "key", "secret")
resp = client.create_bucket("test")
resp # => true
Put Object
resp = client.put_object("bucket_name", "object_key", "myobjectbody")
resp.etag # => ...
You can also pass additional headers (e.g. metadata):
client.put_object("bucket_name", "object_key", "myobjectbody", {"x-amz-meta-name" => "myobject"})
Delete Object
resp = client.delete_object("bucket_name", "object_key")
resp # => true
Check Bucket Existence
resp = client.head_bucket("bucket_name")
resp # => true
Raises an exception if bucket does not exist.
Batch Delete Objects
resp = client.batch_delete("bucket_name", ["key1", "key2"])
resp.success? # => true
Get Object
resp = client.get_object("bucket_name", "object_key")
resp.body # => myobjectbody
List Objects
client.list_objects("bucket_name").each do |resp|
p resp.contents.map(&.key)
end
Upload a file
uploader = Awscr::S3::FileUploader.new(client)
File.open(File.expand_path("myfile"), "r") do |file|
puts uploader.upload("bucket_name", "someobjectkey", file)
end
You can also pass additional headers (e.g. metadata):
uploader = Awscr::S3::FileUploader.new(client)
File.open(File.expand_path("myfile"), "r") do |file|
puts uploader.upload("bucket_name", "someobjectkey", file, {"x-amz-meta-name" => "myobject"})
end
Creating a Presigned::Form.
form = Awscr::S3::Presigned::Form.build("us-east-1", "access key", "secret key") do |form|
form.expiration(Time.unix(Time.now.to_unix + 1000))
form.condition("bucket", "mybucket")
form.condition("acl", "public-read")
form.condition("key", SecureRandom.uuid)
form.condition("Content-Type", "text/plain")
form.condition("success_action_status", "201")
end
You may use version 2 request signing via
form = Awscr::S3::Presigned::Form.build("us-east-1", "access key", "secret key", signer: :v2) do |form|
...
end
Converting the form to raw HTML (for browser uploads, etc).
puts form.to_html
Submitting the form.
data = IO::Memory.new("Hello, S3!")
form.submit(data)
Creating a Presigned::Url.
options = Awscr::S3::Presigned::Url::Options.new(
aws_access_key: "key",
aws_secret_key: "secret",
region: "us-east-1",
object: "test.txt",
bucket: "mybucket",
additional_options: {
"Content-Type" => "image/png"
})
url = Awscr::S3::Presigned::Url.new(options)
p url.for(:put)
You may use version 2 request signing via
options = Awscr::S3::Presigned::Url::Options.new(
aws_access_key: "key",
aws_secret_key: "secret",
region: "us-east-1",
object: "test.txt",
bucket: "mybucket",
signer: :v2
)
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.3.0- Tagged
- Feb 12, 2021
- Commit
f0ecb85c388c- Indexed
- not yet
Dependents
Repository
github.com/repomaa/awscr-s3
Metadata
- Created
- Aug 18, 2026
- Updated
- Nov 11, 2026
- Synced
- Nov 6, 2026
- Versions
- 9