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:

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:

import os
import boto3

filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]

s3 = boto3.client('s3',
	endpoint_url='https://s3.filebase.com',
	aws_access_key_id=filebase_access_key,
	aws_secret_access_key=filebase_secret_key)

response = s3.list_buckets()

# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
    print(f'  {bucket["Name"]}')

11. Then select ‘Run’:

Your Filebase bucket names should be returned:

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

import os
import boto3

filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]

s3 = boto3.client('s3',
	endpoint_url='https://s3.filebase.com',
	aws_access_key_id=filebase_access_key,
	aws_secret_access_key=filebase_secret_key)

bucket_name = "new-filebase-bucket-name"

s3.create_bucket(Bucket=bucket_name)

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:

import os
import boto3

filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]

s3 = boto3.client('s3',
	endpoint_url='https://s3.filebase.com',
	aws_access_key_id=filebase_access_key,
	aws_secret_access_key=filebase_secret_key)

file_path = ""
bucket_name = "filebase-bucket-name"
key_name = "object-name"

s3.put_object(Body=file_path, Bucket=bucket_name, Key=key_name)

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:

import os
import boto3

filebase_access_key = os.environ["FILEBASE_ACCESS_KEY"]
filebase_secret_key = os.environ["FILEBASE_SECRET_KEY"]

s3 = boto3.client('s3',
	endpoint_url='https://s3.filebase.com',
	aws_access_key_id=filebase_access_key,
	aws_secret_access_key=filebase_secret_key)

bucket_name = "filebase-bucket-name"
key_name = "object-name"

s3.get_object(Bucket=bucket_name, Key=key_name)

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 hello@filebase.com

Last updated