Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active December 28, 2023 19:35

Revisions

  1. hkulekci revised this gist Dec 28, 2023. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions 02 - NextCloud.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ## Some commands for NextCloud

    After downloading the files from Box you can insert into NextCloud through command line :

    ```
    # invalid character problems
    # Entry <> will not be accessible due to incompatible encoding
    convmv -f utf-8 -t utf-8 -r --notest --nfc <folder>
    # Scan for next cloud
    cd /var/www/nextcloud
    sudo -u www-data php occ files:scan <username>
    ```
  2. hkulekci revised this gist Dec 28, 2023. No changes.
  3. hkulekci revised this gist Dec 27, 2023. 2 changed files with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions Readme.md → 01 - Readme.md
    Original file line number Diff line number Diff line change
    @@ -2,15 +2,19 @@

    Create an app through developer platform :

    ```
    https://<your-account>.app.box.com/developers/console
    ```

    Then later, get the service account email from the general settings :

    AutomationUser_0000000_xxxxxxx@boxdevedition.com
    ```
    AutomationUser_0000000_xxxxxxx@boxdevedition.com
    ```

    Share the folders with this service account. And run the script as :

    ```
    mkdir backup
    python download_folder.py <folder-id>
    python download.py <folder-id>
    ```
    File renamed without changes.
  4. hkulekci revised this gist Dec 27, 2023. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,15 @@
    ## Usage

    Create an app through developer platform :

    https://<your-account>.app.box.com/developers/console

    Then later, get the service account email from the general settings :

    AutomationUser_0000000_xxxxxxx@boxdevedition.com

    Share the folders with this service account. And run the script as :

    ```
    mkdir backup
    python download_folder.py <folder-id>
  5. hkulekci created this gist Dec 27, 2023.
    6 changes: 6 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    ## Usage

    ```
    mkdir backup
    python download_folder.py <folder-id>
    ```
    28 changes: 28 additions & 0 deletions download_folder.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    import os
    from boxsdk import Client, OAuth2
    import sys

    auth = OAuth2(
    client_id='client-id',
    client_secret='',
    access_token='primary-access-token'
    )
    client = Client(auth)
    service_account = client.user().get()
    print(f'Service Account user ID is {service_account.id}')
    print(service_account)
    folder = client.folder(sys.argv[1])
    print(folder.get().name)

    def recursively_download(folder, path=None):
    os.makedirs(path, exist_ok=True)
    for item in folder.get_items():
    print(f"{item.name} - {item.type}")
    if item.type == 'folder':
    recursively_download(item, f"{path}/{item.name}")
    elif item.type == 'file':
    output_file = open(f"{path}/{item.name}", 'wb')
    item.download_to(output_file)


    recursively_download(folder, f"backup/{folder.get().name}")