DataCamp
Learn how to configure DataCamp for use with Filebase.

What is DataCamp?

DataCamp is an online learning platform that allows users to build and develop programming and data science skills from browser-based development environments. DataCamp offers a wide variety of tutorials, courses, and educational resources that engage students in an interactive interface to learn about coding.
Read below to learn how to use DataCamp with Filebase.

Prerequisites:

  • Have your Filebase Access and Secret Keys. Learn how to view your access keys here.
  • Create a Filebase Bucket. Learn how to create a bucket here.

1. Login to your DataCamp dashboard.

From the dashboard, select ‘Workspace’ from the top navigation menu bar.

2. Select a workspace you’d like to connect to Filebase.

This example uses a Python-based workspace:

3. Then select ‘Integrations’ from the left sidebar navigation menu.

4. Select ‘Create Integration’:

5. Select ‘Environment Variables’:

6. Enter two variables, FILEBASE_ACCESS_KEY and FILEBASE_SECRET_KEY.

For the value of these variables, enter your Filebase Access Key and Filebase Secret Key. Name this integration ‘Filebase Keys’. Then select ‘Create’.

7. Copy the provided integration code, then select ‘Next’:

8. Select ‘Connect’ when prompted to connect your workspace to your newly created integration:

9. Next, select ‘Add code’ at the bottom of your workspace to add a new piece of code.

10. To list all the buckets on your Filebase account, enter the following piece of code:

1
import os
2
import boto3
3
4
filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
5
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]
6
7
s3 = boto3.client('s3',
8
endpoint_url='https://s3.filebase.com',
9
aws_access_key_id=filebase_access_key,
10
aws_secret_access_key=filebase_secret_key)
11
12
response = s3.list_buckets()
13
14
# Output the bucket names
15
print('Existing buckets:')
16
for bucket in response['Buckets']:
17
print(f' {bucket["Name"]}')
Copied!

11. Then select ‘Run’:

Your Filebase bucket names should be returned:

12. To create a new Filebase bucket, use the following piece of code:

1
import os
2
import boto3
3
4
filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
5
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]
6
7
s3 = boto3.client('s3',
8
endpoint_url='https://s3.filebase.com',
9
aws_access_key_id=filebase_access_key,
10
aws_secret_access_key=filebase_secret_key)
11
12
bucket_name = "new-filebase-bucket-name"
13
14
s3.create_bucket(Bucket=bucket_name)
Copied!

13. Then select ‘Run’:

The response data should resemble the following, including a 200 HTTP Status Code indicating the success:

14. To upload an object from your workspace to Filebase, use the following code:

1
import os
2
import boto3
3
4
filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
5
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]
6
7
s3 = boto3.client('s3',
8
endpoint_url='https://s3.filebase.com',
9
aws_access_key_id=filebase_access_key,
10
aws_secret_access_key=filebase_secret_key)
11
12
file_path = ""
13
bucket_name = "filebase-bucket-name"
14
key_name = "object-name"
15
16
s3.put_object(Body=file_path, Bucket=bucket_name, Key=key_name)
Copied!
Replace filebase-bucket-name with your Filebase bucket name, and object-name with the name of the file to be uploaded.

15. Then select ‘Run’ to run the code:

The response data should resemble the following, including a 200 HTTP Status Code indicating the success:

16. You can verify that the file has been uploaded by navigating to the Filebase web console and viewing the contents of your bucket:

17. To download an object to your workspace, use the following code:

1
import os
2
import boto3
3
4
filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
5
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]
6
7
s3 = boto3.client('s3',
8
endpoint_url='https://s3.filebase.com',
9
aws_access_key_id=filebase_access_key,
10
aws_secret_access_key=filebase_secret_key)
11
12
bucket_name = "filebase-bucket-name"
13
key_name = "object-name"
14
15
s3.get_object(Bucket=bucket_name, Key=key_name)
Copied!
Replace filebase-bucket-name with your Filebase bucket name, and object-name with the name of the file to be uploaded.

18. Then select ‘Run’ to run the code:

The response data should resemble the following, including a 200 HTTP Status Code indicating the success:
If you have any questions, please join our Discord server, or send us an email at [email protected]