Terminus has a Dropbox Business Account, where our team can create a shared folder and share that folder directly with your team. From here, the customer will be able to access the shared folder and upload the necessary files from their system.
A shared folder in Dropbox is any folder that you’ve invited other people to view or edit—even if they’re outside your team. Anyone with shared folder access can see all the files in that folder, but nothing else outside of that folder. Files in shared folders sync between members’ Dropbox accounts, so each member of a shared folder needs a Dropbox account.
You can leverage an already existing dropbox account or can register for a free Dropbox account here: https://www.dropbox.com/register
- Dropbox Account
- Access to the .CSV file to be shared with Terminus
How to Gain Access to the Shared Folder
1. Please provide your Technical Consultant with the email address of the dropbox account you will be uploading files from. The Technical Consultant can then create a Shared folder with this account
2. You will receive an email in your inbox which notifies the folder was shared with you. Please click the “Go to folder” button:
3. If you have not signed into your account, you will be prompted to sign in. Please sign into the correct account the folder has been shared with. You will then be prompted with a message. Please click the “Add to Dropbox” button:
4. The folder will now be accessible from your account and you will be able to upload the necessary files.
How To Upload
- Log into your Dropbox account at https://www.dropbox.com/login
- Navigate to the shared Terminus folder and locate the “Upload Files” button
- After clicking on the “Upload Files” button, please select and upload the data files that you will be sharing with Terminus.
- Upon a successful upload, you will see the file in the shared folder. At this point, Terminus will take the data files and import them into Data Studio.
How to Set Up Dropbox API to Automatically Upload Files
The Dropbox API allows seamless integration with your business workflow, enabling efficient file management and collaboration. By following the steps outlined below, you will be able to programmatically upload files using Dropbox API within a Terminus shared folder.
Before proceeding with the file upload process, ensure that you have the following prerequisites in place:
- Access to a Dropbox Business account with appropriate permissions.
- Familiarity with programming languages and APIs, preferably with experience in working with RESTful APIs.
- An active Dropbox API app with the necessary access token and permission scopes.
Step 1: Authentication and Authorization
To start uploading files to a shared folder, you must authenticate and authorize your Dropbox API app with the appropriate permissions. Follow these steps:
- Generate an access token for your Dropbox API app with the required permission scopes.
- Store the access token securely in your application.
Step 2: Locating the Shared Folder
To upload files to a shared folder, you need to identify the folder's unique identifier. Follow these instructions:
- Retrieve the shared folder metadata by calling the sharing/list_folders endpoint of the Dropbox API, providing the access token.
- Identify the desired shared folder within the response based on its name or other attributes.
- Note down the shared folder's unique identifier for future reference.
Step 3: Uploading Files
Now that you have the access token and the shared folder's unique identifier, you can proceed with uploading files programmatically. Use the following steps:
- Identify the file(s) you want to upload and ensure that they are accessible from your application.
- Prepare an HTTP POST request to the Dropbox API endpoint files/upload_session/start.
- Set the appropriate headers, including the access token and content type.
- Include the file's content as the request payload.
- Send the request to initiate the file upload session and retrieve a unique session identifier.
- Split the file into smaller chunks (e.g., 4 MB) and send subsequent HTTP requests to the files/upload_session/append_v2 endpoint, providing the session identifier, cursor position, and respective file chunk.
- Continue appending chunks until the entire file is uploaded.
- Finalize the upload session by sending an HTTP POST request to the files/upload_session/finish endpoint, including the session identifier and other necessary parameters.
- Verify the response to ensure the file upload was successful.
Python Code Example:
# Specify your app's access token
access_token = "YOUR_ACCESS_TOKEN"
# Create a Dropbox API client
dbx = dropbox.Dropbox(access_token)
# Specify the path of the file to be uploaded
file_path = "/path/to/file.pdf"
# Specify the destination path within the shared folder
destination_path = "/Shared Folder/Subfolder/file.pdf"
# Open the file for reading
with open(file_path, "rb") as file:
# Start the upload session
session_start_result = dbx.files_upload_session_start(file.read())
# Obtain the session identifier and cursor position
session_id = session_start_result.session_id
cursor = dropbox.files.UploadSessionCursor(session_id=session_id, offset=file.tell())
# Append file chunks until the entire file is uploaded
while file.tell() < session_start_result.offset:
if file.tell() + CHUNK_SIZE > session_start_result.offset:
# Last chunk
dbx.files_upload_session_finish(file.read(CHUNK_SIZE), cursor, dropbox.files.CommitInfo(path=destination_path))
# Intermediate chunk
cursor.offset = file.tell()
print("File uploaded successfully!")
Please sign in to leave a comment.