Skip to content

Commit c115b9a

Browse files
authored
Merge pull request #158 from tigrisdata/Xe/TIG-3545
docs/sdks/s3/ruby: move examples to their own files
2 parents f275c82 + 170de95 commit c115b9a

File tree

4 files changed

+78
-20
lines changed

4 files changed

+78
-20
lines changed

docs/sdks/s3/aws-ruby-sdk.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# AWS Ruby SDK
2+
3+
import CodeBlock from "@theme/CodeBlock";
4+
5+
This guide assumes that you have followed the steps in the
6+
[Getting Started](/docs/get-started/index.md) guide, and have the access keys
7+
available.
8+
9+
You may continue to use the AWS Ruby SDK as you normally would, but with the
10+
endpoint set to `https://fly.storage.tigris.dev`.
11+
12+
This example uses the [AWS Ruby SDK v3](https://github.com/aws/aws-sdk-ruby) and
13+
reads the default credentials file or the environment variables
14+
`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
15+
16+
import Gemfile from "!!raw-loader!../../../examples/ruby/Gemfile";
17+
18+
<CodeBlock language="ruby">{Gemfile}</CodeBlock>
19+
20+
Then you can use the SDK as you normally would, but with the endpoint set to
21+
`https://fly.storage.tigris.dev`.
22+
23+
import gettingStarted from "!!raw-loader!../../../examples/ruby/getting_started.rb";
24+
25+
<CodeBlock language="ruby">{gettingStarted}</CodeBlock>

examples/ruby/Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem 'nokogiri', '~> 1.11'
6+
# highlight-start
7+
gem 'aws-sdk-s3', '~> 1'
8+
# highlight-end

examples/ruby/Gemfile.lock

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
aws-eventstream (1.3.0)
5+
aws-partitions (1.1048.0)
6+
aws-sdk-core (3.218.1)
7+
aws-eventstream (~> 1, >= 1.3.0)
8+
aws-partitions (~> 1, >= 1.992.0)
9+
aws-sigv4 (~> 1.9)
10+
base64
11+
jmespath (~> 1, >= 1.6.1)
12+
aws-sdk-kms (1.98.0)
13+
aws-sdk-core (~> 3, >= 3.216.0)
14+
aws-sigv4 (~> 1.5)
15+
aws-sdk-s3 (1.180.0)
16+
aws-sdk-core (~> 3, >= 3.216.0)
17+
aws-sdk-kms (~> 1)
18+
aws-sigv4 (~> 1.5)
19+
aws-sigv4 (1.11.0)
20+
aws-eventstream (~> 1, >= 1.0.2)
21+
base64 (0.2.0)
22+
jmespath (1.6.2)
23+
mini_portile2 (2.8.8)
24+
nokogiri (1.18.2)
25+
mini_portile2 (~> 2.8.2)
26+
racc (~> 1.4)
27+
nokogiri (1.18.2-arm64-darwin)
28+
racc (~> 1.4)
29+
racc (1.8.1)
30+
31+
PLATFORMS
32+
arm64-darwin-24
33+
ruby
34+
35+
DEPENDENCIES
36+
aws-sdk-s3 (~> 1)
37+
nokogiri (~> 1.11)
38+
39+
BUNDLED WITH
40+
2.6.2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
# AWS Ruby SDK
1+
require "aws-sdk-s3"
22

3-
This guide assumes that you have followed the steps in the
4-
[Getting Started](/docs/get-started/index.md) guide, and have the access keys
5-
available.
6-
7-
You may continue to use the AWS Ruby SDK as you normally would, but with the
8-
endpoint set to `https://fly.storage.tigris.dev`.
9-
10-
This example uses the [AWS Ruby SDK v3](https://github.com/aws/aws-sdk-ruby) and
11-
reads the default credentials file or the environment variables
12-
`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
13-
14-
```ruby
15-
require "aws-sdk"
16-
17-
bucket_name = "foo-bucket"
3+
bucket_name = "tigris-example"
184

195
s3 = Aws::S3::Client.new(
206
region: "auto",
@@ -30,7 +16,7 @@
3016
end
3117

3218
# List the first ten objects in the bucket
33-
resp = s3.list_objects(bucket: 'foo-bucket', max_keys: 10)
19+
resp = s3.list_objects(bucket: bucket_name, max_keys: 10)
3420
resp.contents.each do |object|
3521
puts "#{object.key} => #{object.etag}"
3622
end
@@ -41,11 +27,10 @@
4127
s3.put_object(
4228
bucket: bucket_name,
4329
key: file_name,
44-
body: File.read("bar.txt")
30+
body: File.read("getting_started.rb")
4531
)
4632
puts "Uploaded #{file_name} to #{bucket_name}."
4733
rescue Exception => e
4834
puts "Failed to upload #{file_name} with error: #{e.message}"
4935
exit "Please fix error with file upload before continuing."
50-
end
51-
```
36+
end

0 commit comments

Comments
 (0)