# DataCamp

## 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.

{% hint style="success" %}

### Prerequisites:

* [x] [Sign up](https://filebase.com/signup) for a free Filebase account.&#x20;
* [x] Have your Filebase Access and Secret Keys. Learn how to view your access keys [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#working-with-access-keys).
* [x] Create a Filebase Bucket. Learn how to create a bucket [here](https://docs.filebase.com/getting-started-guides/getting-started-guide#creating-and-working-with-buckets).
  {% endhint %}

### 1. [Login](https://www.datacamp.com/onboarding) to your DataCamp dashboard.

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FetOssgm9jdkEKnYYCsTU%2Fimage.png?alt=media\&token=c336cb1c-02f6-4a3e-866e-37de0c93b030)

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

This example uses a Python-based workspace:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2Fff9GfZ5wdnUDJK8gVLft%2Fimage.png?alt=media\&token=7c033a4d-2312-47bd-a7b3-03bd98d0934c)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FXeAkENe6y6PxK1kcvJUr%2Fimage.png?alt=media\&token=4a4b31b7-58a6-4df2-9681-5d3a81031f82)

### 4. Select ‘Create Integration’:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FGhNSzxiAlqpGPCIKQiyY%2Fimage.png?alt=media\&token=579e6f14-6c90-4965-ace0-1dc6139d8f4e)

### 5. Select ‘Environment Variables’:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FFPxv37xiUOPbWksmH0lz%2Fimage.png?alt=media\&token=f84febf3-8c87-47ea-a3aa-109c733133de)

### 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’.

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FBLOd5Io60rumL1R3Awnt%2Fimage.png?alt=media\&token=0c673e6b-8e53-4794-8981-adb5b7923949)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FC7QZb8fxjEkRyBoXyHkQ%2Fimage.png?alt=media\&token=d688017b-0f77-4345-a0a3-aba2966752b8)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2F730k0q9TSE3dmJ0yLCNo%2Fimage.png?alt=media\&token=1127c118-14fa-49ac-8eb0-9e1546037395)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FWGJORTNqsqMF3NLQ24fV%2Fimage.png?alt=media\&token=0e45f008-7864-41ce-bcbf-14863117a3f5)

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

```python
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’:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FExdIUOc9qFKTe5TqIn82%2Fimage.png?alt=media\&token=2c8f79f4-081f-465e-b3d0-6c473c5c7467)

Your Filebase bucket names should be returned:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FgoBGEWyrNycztQNj5a95%2Fimage.png?alt=media\&token=72609934-5e4a-40bb-a7ca-67b83e41f4c7)

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

```python
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’:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FhjfbiCdoxulnhQJ2Qcs0%2Fimage.png?alt=media\&token=f99c3382-a3bd-43f4-95a6-f1055dd92fe0)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2Fpd0sMK0qqt16itsNSAFK%2Fimage.png?alt=media\&token=02d5361c-0b77-4400-bced-77acb5ca5b8e)

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

```python
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:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FWI3dgGoERjPjUCuXyqM2%2Fimage.png?alt=media\&token=32a03316-1a44-457d-85a7-fc5c0b64609e)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FB8qsBULnFFbHVnTy3S5x%2Fimage.png?alt=media\&token=0176130c-7928-4fbe-9563-2a8667ef3811)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FsX1uG1beN4lFdrLopSeh%2Fimage.png?alt=media\&token=56012a8c-d150-40df-84d4-3abe79b7a7b7)

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

```python
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:

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FQmkHZ6tH8Fr92XEF484b%2Fimage.png?alt=media\&token=28c12d60-d6f5-48cf-a6c5-5414f39a5a72)

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

![](https://3861818989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lyjw7dWpiQtUFDa1pO0%2Fuploads%2FnxVKXsSimiUDAZjPxNb7%2Fimage.png?alt=media\&token=d2942e39-a92f-4a29-83ce-7530b065eee8)
