O4WI_Upload_Dropbox routine
Description
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.
Syntax
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
Remarks
OpenInsight 10.0.8 and above.