AWS SDK for Ruby
Learn how to pin files and folders to IPFS using the AWS SDK for Ruby.
AWS SDKs (software development kits) help simplify coding and application development by supporting and providing code objects for use with S3-compatible services. There are a variety of different AWS SDKs, each for a different coding language. This guide covers AWS SDK - Ruby.
A .car file is a type of compressed archive file that contains multiple files, similar to a ZIP file. .car files are used by the FileCoin and IPFS networks, which utilize the metadata fields to include the IPFS CIDs of each file within the archive.
Read below to learn how to pin files and folders to IPFS using the AWS SDK for Ruby.



The following code example uploads an object to the specified bucket. Replace the following values in the code to match your configuration:
- filebase-access-key: Your Filebase Access Key
- filebase-secret-key: Your Filebase Secret Key
- filebase-bucket-name: The Filebase Bucket Name
- /path/to/object/to/upload: The file path to the object that you want to be uploaded to IPFS
- Object-name: The desired object name once uploaded
require 'aws-sdk-s3'
s3 = Aws::S3::Client.new(
access_key_id: 'filebase-access-key',
secret_access_key: 'filebase-secret-key',
region: 'us-east-1',
endpoint: 'https://s3.filebase.com'
)
bucket_name = 'filebase-bucket-name'
object_key = 'object-name'
object_path = '/path/to/object/to/upload'
File.open(object_path, 'rb') do |file|
s3.put_object(bucket: bucket_name, key: object_key, body: file)
end
git clone https://github.com/web3-storage/ipfs-car
npx ipfs-car
This has been tested with .car archives containing 10,000 or more files. Use any of the following commands, depending on your desired workflow:
ipfs-car --pack path/to/file/or/dir
ipfs-car --pack path/to/files --output path/to/write/ipfs-car.car
The following code example uploads an object to the specified bucket. Replace the following values in the code to match your configuration:
- filebase-access-key: Your Filebase Access Key
- filebase-secret-key: Your Filebase Secret Key
- filebase-bucket-name: The Filebase Bucket Name
- /path/to/object/to/upload: The file path to the .car file that you want to be uploaded to IPFS
- Object-name: The desired object name once uploaded
require 'aws-sdk-s3'
s3 = Aws::S3::Client.new(
access_key_id: 'filebase-access-key',
secret_access_key: 'filebase-secret-key',
region: 'us-east-1',
endpoint: 'https://s3.filebase.com'
)
bucket_name = 'filebase-bucket-name'
object_key = 'ipfs-car.car'
object_path = '/path/to/object/to/upload'
File.open(object_path, 'rb') do |file|
s3.put_object(bucket: bucket_name, key: object_key, body: file)
end
If you have any questions, please join our Discord server, or send us an email at [email protected]