IPFS-CAR
Learn how to convert files and folders into content-addressable archive (.car) files and upload them to IPFS through Filebase.

What is a .car file?

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.
Filebase supports uploading .car files to IPFS using the S3-compatible API through the PutObject or MultipartUpload methods.
Read below to learn how to convert files and folders into content-addressable archive (.car) files and upload them to IPFS through Filebase.

Prerequisites:

1. Download the ipfs-car package with the following command:

git clone https://github.com/web3-storage/ipfs-car

2. Install the ipfs-car package:

npx ipfs-car

3. Next, use ipfs-car to package a folder of files into a .car file.

This has been tested with .car archives containing 10,000 or more files. Use any of the following commands, depending on your desired workflow:

Write a .car file to the current working directory

ipfs-car --pack path/to/file/or/dir

Write a .car file to a specific directory with a specified name

ipfs-car --pack path/to/files --output path/to/write/a.car

4. You can view the contents of the .car file with the following commands:

List the CIDs for each file in the .car archive:

ipfs-car --list-cids path/to/my.car

List the file names for each file in the .car archive:

ipfs-car --list path/to/my.car

5. Next, upload your .car file to Filebase using the following AWS CLI command:

aws --endpoint https://s3.filebase.com s3 cp file-name.car s3://bucket-name --debug --metadata 'import=car'
Replace file-name with your .car file name, and bucket-name with your Filebase IPFS bucket name. Below is an example:
aws --endpoint https://s3.filebase.com s3 cp TEST_CAR.car s3://ipfs-test --debug --metadata 'import=car'
When you upload a .car file, you can pass an S3 metadata header of x-amz-meta-import: car along with the request. Filebase will then import the file as a .car, and return the resulting CID.
With the specified –debug flag, the response headers are shown, which reveal the CID:
2022-06-14 19:51:41,400 - ThreadPoolExecutor-0_2 - botocore.parsers - DEBUG - Response headers: {'Date': 'Tue, 14 Jun 2022 23:51:41 GMT', 'Content-Type': 'application/xml', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'x-amz-meta-cid': 'bafybeieurpeyzighqrvwjqyj3szuvbqvrbijm7cdair5a422ipf2d5qnlq', 'ETag': 'W/"d8cad258a3d9bbe03a26a13a3ec43b21"', 'x-amz-request-id': '144e0415-8162-45cd-b071-e51dada956ae', 'x-amz-id-2': 'ZmlsZWJhc2UtNmQ3ZjQ5OGZmZC14ejk1Mg==', 'Server': 'Filebase'}
To learn more about ipfs-car and for additional use cases using the ipfs-car API, see the ipfs-car documentation here.
If you have any questions, please join our Discord server, or send us an email at [email protected]
Last modified 29d ago
Copy link
On this page
What is a .car file?
1. Download the ipfs-car package with the following command:
2. Install the ipfs-car package:
3. Next, use ipfs-car to package a folder of files into a .car file.
4. You can view the contents of the .car file with the following commands:
5. Next, upload your .car file to Filebase using the following AWS CLI command: