Views:

Related resources:

Tutorials

Providing you are a LUSID user with sufficient privileges, you can upload files to Drive and perform standard file management operations on those files. 

Note: If you are the LUSID domain owner, you are automatically assigned the built-in lusid-administrator role, which has all the permissions necessary to perform the operations in this article. To see how to grant other users permission to use Drive, follow this tutorial

Note the following:

  • Files uploaded to Drive, and folders you create to organise files within Drive, must have names between 1 and 50 characters long, consisting of alphanumeric, dash (-) or underscore (_) characters only. 
  • Files cannot be empty, nor larger than 500MB.

You can interact with Drive graphically in the LUSID web app, or programmatically using the Drive API. 

Using the LUSID web app 

To upload a file:

  1. Sign in to the LUSID web app using the credentials of a LUSID administrator.
  2. From the left-hand menu, select Data Management > Drive:
  3. On the Drive dashboard, click the Upload file button (top right), and follow the instructions:
     

You can perform standard file management operations from the Drive dashboard. For example, you can:

  • Create folders using the Create folder button (top right).
  • Download a file (not a folder) by clicking the  Actions icon for a file row to open its shortcut menu.
  • Rename a file or folder. Note names are classed as metadata on the underlying object.
  • Copy link to share a file or folder by copying a URL to the Clipboard. Note recipients must be users in your LUSID domain with suitable permissions to use Drive.
  • Move a file (not a folder). Note you can bulk move by selecting file rows and choosing Move from the Choose action dropdown (above the rows):

Using the Drive API

To upload a file:

  1. Obtain an API access token.
  2. Call the Drive POST /api/files API endpoint for your LUSID domain, passing in your API access token and the following parameters (see comments for details):
    curl -X POST "https://<your-domain>.lusid.com/drive/api/files"
       -H "Authorization: Bearer <your-access-token>"
       -H "Content-Type: application/octet-stream"
       -H "x-lusid-drive-filename: trade-file.csv"                  # This is the name of the file as you want it to appear in Drive
       -H "x-lusid-drive-path: /Instruments"                        # This is the intended folder location in Drive; "/" signifies the root folder
       -H "Content-Length: 2220"                                    # This is the file size in bytes; it must be accurate
       --data-binary @my-trade-file.csv                             # This is the path to the local file you want to upload
    
    The response contains an automatically-generated id that uniquely identifies the file in Drive:
    {
        "id": "aab46045-df2f-4446-a6e3-6af269d9c26f",
        "path": "/Instruments",
        "name": "trade-file.csv",
        "createdBy": "00u91lo2d7X46sdse2p7",
        "createdOn": "2021-07-16T14:27:41.5827803+00:00",
        "updatedBy": "00u91lo2d7X46sdse2p7",
        "updatedOn": "2021-07-16T14:27:41.5827803+00:00",
        "type": "File",
        "size": 2220,
        "status": "Active",
        "links": [
            {
                "relation": "Downloads",
                "href": "https://<your-domain>.lusid.com/drive//api/files/aab46045-df2f-4446-a6e3-6af269d9c23f/contents",
                "description": "Download this file",
                "method": "GET"
            },
            {
                "relation": "Folder",
                "href": "https://<your-domain>.lusid.com/drive//api/folders/cbc62475-6b26-4ba5-a7ec-27f5b96f042f/folders",
                "description": "The folder in which this file resides",
                "method": "GET"
            },
            {
                "relation": "RequestLogs",
                "href": "http://<your-domain>.lusid.com/app/insights/logs/0HMA870NNCJ4O:00000001",
                "description": "A link to the LUSID Insights website showing all logs related to this request",
                "method": "GET"
            }
        ]
    }

Note you can search for a particular file or folder using the Drive POST /api/search API endpoint. If no path is specified, the root folder is searched recursively. All the metadata required to interact with object(s) is returned in the response.

Note also that the following Drive API endpoints support result filtering:

  • GET /api/folders - List the contents of the root folder
  • GET /api/folders/{id}/contents - List the contents of a particular folder
  • POST /api/search - Search for a particular file or folder

Automatic virus scanning

Every file uploaded to Drive, or whose content is modified whilst stored in Drive, is automatically scanned for malware. Note the following scan stages:

Stage Implication File state or error code
Virus scan in progress You cannot download a file while a scan is in progress. 716 VirusScanInProgress
(HTTP 423)
Malware detected You can see the file in the list of files and delete it as normal but you cannot download a file containing malware. The response body of the API call contains the reason. 715 MalwareDetected 
(HTTP 410)
Virus scan passed The file is clean and ready to use. Available
Virus scan failed The scan could not be performed. Failed