Skip to content

Instantly share code, notes, and snippets.

@justinTM
Created April 16, 2020 00:45
Show Gist options
  • Save justinTM/bf48484f372c51778212a1de33be460e to your computer and use it in GitHub Desktop.
Save justinTM/bf48484f372c51778212a1de33be460e to your computer and use it in GitHub Desktop.
Using Python (`boxsdk`, `requests`, and `tqdm` modules), all files from a Box folder -- specified by ID -- are downloaded via URL. Yes the binary can simply be downloaded with the Box SDK methods.
from boxsdk import DevelopmentClient
import requests
from tqdm.auto import trange
client = DevelopmentClient()
user = client.user().get()
folder = client.folder(folder_id='XXXXXXXXXXXX')
files = [item for item in folder.get_items()]
print('Beginning file download with requests...')
for i in trange(len(files)):
url = files[i].get_download_url()
r = requests.get(url)
with open('../../Folder/'+item.name, 'wb') as f:
f.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment