O4W Dropbox Integration


In OpenInsight 10.0.8 and later, O4W provides enhancments to integrate with Dropbox (https://www.dropbox.com), an on-line file hosting service.  With these enhancements, you can provide "upload" links directly to your Dropbox account (rather than hosting file uploads on your own server).  The changes include a new routine O4W helper routine (O4WI_UPLOAD_DROPBOX), a general Dropbox utility (RTI_UTIL_DROPBOX), and changes to current O4W routines (O4WUPLOADBOX and O4WUPLOADBOXOPTIONS).

O4WI_UPLOAD_DROPBOX

The O4WI_UPLOAD_DROPBOX routine is an enhancement routine that allows O4WUPLOADBOX to upload files directly to Dropbox.  To use it, specify "@O4WI_UPLOAD_DROPBOX" as the "destination" parameter in the O4WUPLOADBOX call.

O4WI_UPLOAD_DROPBOX requires that a configuration record (CFG_DROPBOX) be created in the SYSENV table; this record may be global (CFG_DROPBOX), or application specific (CFG_DROPBOX*<appid>), or user-specific (CFG_DROPBOX**<userid>), or application and user specific (CFG_DROPBOX*<appid>*<userid>).  The contents of the record must be:

1. The URL to the dropbox API you wish to use to create a temporary upload link - for example, https://api.dropboxapi.com/2/files/get_temporary_upload_link
2. Your unique "authorization key" generated for your Dropbox account - you must request this key from Dropbox if you wish to use their API
3. (optional) The duration a temporary link will remain valid (leave empty to use the default)
4. (optional) The folder and/or file name to upload to
5. (optional) The comma-delimited list of file extensions that are allowed to be uploaded.  Note that this is a list of just the 3-4 character extensions, in lower case, without any leading "." or other characters.  For example:  jpg,jpeg,png

For more information on getting your Dropbox authorization key, see https://www.dropbox.com/developers/reference/getting-started

When O4WUPLOADBOX calls O4WI_UPLOAD_DROPBOX, any information you pass in as the "original value" will be used to generate the file name in dropbox.  If a folder and/or file name is specified in the configuration record, it will be used to "prefix" that original value.  In any case, any "#" character will be converted to DATE():TIME():"_"

This routine will generate and store the temporary upload link that will - in conjunction with O4W's scripting language - send the uploaded file to Dropbox.

Note: If you are using the O4W Form Wizard to create an "uploadbox" control, you cannot specify O4WI_UPLOAD_DROPBOX as the destination directly, as the O4W Form Wizard already allowed for some programmatic generation of the destination value, with different parameters.  Instead, you must create a helper (or "shim") routine that is called by the O4W Form Wizard, and which then in turn provides the O4WI_UPLOAD_DROPBOX call.  For example, you might create the following routine:

Subroutine MY_DROPBOX_UPLOAD_SHIM(P1, P2, DESTN)
Declare Function rti_get_cfg
dpCfg = rti_get_cfg("CFG_DROPBOX")
If dpCfg<1> <> "" And dpCfg<2> <> "" then
     DESTN = "@O4WI_UPLOAD_DROPBOX"
End Else
     destn = "D:\OI_WEBWIZ\ERRORS\^.$"
END
Return 0

Then, in the O4W Form Wizard, in the file upload element(s) that you wish to enable for Dropbox, specify @MY_DROPBOX_UPLOAD_SHIM for the "Upload Destination:" value

RTI_UTIL_DROPBOX

The RTI_UTIL_DROPBOX utility provides a way to programmatically copy, move, rename, download, or delete a dropbox file.

RTI_UTIL_DROPBOX requires that a configuration record (CFG_DROPBOX) be created in the SYSENV table; this record may be global (CFG_DROPBOX), or application specific (CFG_DROPBOX*<appid>), or user-specific (CFG_DROPBOX**<userid>), or application and user specific (CFG_DROPBOX*<appid>*<userid>).  The contents of the record must be:

1. The URL to the dropbox API you wish to use to create a temporary upload link - for example, https://api.dropboxapi.com/2/files/get_temporary_upload_link
2. Your unique "authorization key" generated for your dropbox account - you must request this key from Dropbox if you wish to use their API
3. (optional) The duration a temporary link will remain valid (leave empty to use the default)
4. (optional) The folder and/or file name to upload to
5. (optional) The comma-delimited list of file extensions that are allowed to be uploaded.  Note that this is a list of just the 3-4 character extensions, in lower case, without any leading "." or other characters.  For example:  jpg,jpeg,png

For more information on getting your Dropbox authorization key, see https://www.dropbox.com/developers/reference/getting-started

The interface to the RTI_UTIL_DROPBOX function is:

Function  RTI_UTIL_DROPBOX(action, param1, param2, param3, param4, response)

where action is one of the following:

MOVE

RENAME

COPY

DOWNLOAD

DOWNLOAD_ZIP

UPLOAD

UPLOAD_DIRECT

UPLOAD_FILE

DELETE

UPLOAD_LINK

SHARE_LINK

For each action, the parameters are as follows (NOTE: for any path and file name parameters, if the configuration record field #4 is non-null, and the parameter does not start with a "/", then the parameter will be prefixed with the configuration record information.  Also note that any "#" in any file name parameters will be replaced with the current DATE():TIME():"_" string.  The changed parameter's value will be returned in the same parameter):

MOVE: Move a file from one Dropbox folder to another
param1: The source path and file name on Dropbox
param2: The destination path and file name on Dropbox

RENAME: Change the name of a dropbox file (note that you must still specify full paths for the original and new file name)
param1: The source path and file name on Dropbox
param2: The new path and file name on Dropbox

COPY: Duplicate the source dropbox file to the destination dropbox folder and name
param1: The source path and file name on Dropbox
param2: The new path and file name to create on Dropbox

DOWNLOAD: Download the content of the specified dropbox file to your local workstation
param1: The source path and file name on Dropbox
param2: (Optional) The file path and name on your location workstation where the data should be written.  If not specified, the data is returned as the function result

DOWNLOAD_ZIP: Download the entire contents of the specified dropbox folder as a zip file to your local workstation
param1: The source path on Dropbox.  Note that this is a PATH ONLY and should NOT specify an individual file
param2: (Optional) The file path and name on your location workstation where the zip file data should be written.  If not specified, the data is returned as the function result

UPLOAD: Upload the specified file or value to a Dropbox file
param1: The destination path and file name on Dropbox
param2: The explicit content to upload, or the name of the operating system file on the Workstation
param3: "F" if param2 is a path and filename that contains plain-text data; "FB" if param2 is a path and filename that contains binary data; "b" if param2 is the literal binary data to upload; "" if param2 is the literal plain-text data to upload
param4: "1" if any existing Dropbox file with the same name should be overwritten; "0" or null if overwrite is forbidden


UPLOAD_DIRECT: Upload the specified value to a Dropbox file
param1: The destination path and file name on Dropbox
param2: The explicit content to upload
param3: "1" if param2 is binary data to upload; "" or "0" if param2 is the plain-text data to upload
param4: "1" if any existing Dropbox file with the same name should be overwritten; "0" or null if overwrite is forbidden


UPLOAD_FILE: Upload the specified file to a Dropbox file
param1: The destination path and file name on Dropbox
param2: The name of the operating system file on the Workstation
param3: "1" if the file specified in param2 contains binary data; "" or "0" if param2 specifies a file with plain-text data
param4: "1" if any existing Dropbox file with the same name should be overwritten; "0" or null if overwrite is forbidden

DELETE:  Delete the named Dropbox file from the specified location
param1: The path and file name on Dropbox to delete

UPLOAD_LINK: Generate a temporary upload link to use for uploading a file to a specific location on Dropbox
param1: The path and file name on Dropbox where the file should be uploaded to

SHARE_LINK: Generate a 'shared link' to allow others to view a Dropbox file or folder
param1: The path (and optionally file name) on Dropbox that you wish to share via link
param2: The settings for the share.  Field 1 is an @VM delimited array of setting names (including requested_visibility, audience, and/or access); Field 2 is the associated @VM delimited array of setting values


This function will normally return "OK" if the processing completed successfully, and "ERROR" (possibly followed by additional error information in field 2) if there were any errors during processing.  In certain circumstances (for example, DOWNLOAD and DOWNLOAD_ZIP actions), the return result may be the file contents themselves or "ERROR"; for the UPLOAD_LINK and SHARE_LINK actions, the return result will be the URL or "ERROR".

In all cases, the response parameter (if present) will be filled in with the response to the call from Dropbox.

Revelation Conference

Revelation Software does not have a Conference scheduled for 2019.  Click the button below for our previous Conference web site.

Click Here

On The Road

Throughout the year Revelation Software attends various multivalue User Conferences as well as our Regional User Group meetings.

Click Here

International Offices

Revelation Software has various International Offices and sales regions located on multiple continents.

Click Here

Featured Clients

Revelation Software's clients are involved in every industry around the world. Here is a sampling of some of our clients and their businesses

Click Here