open-insight/SYSPROG/STPROC/O4WI_UPLOAD_DROPBOX.txt
2024-03-25 15:17:34 -07:00

86 lines
2.6 KiB
Plaintext

Subroutine O4WI_UPLOAD_DROPBOX(origvalue, destn, size, name, ID, StyleInfo)
*#!Precompile
/*
* This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without
* written permission from Revelation Technologies, Inc.
!
*
* VERSION : 1.0
*
*
* AUTHOR : Bryan Shumsky
*
* CREATED : November 6, 2019
*
*
!
*
* REVISION HISTORY (Most CURRENT first) :
*
* DATE IMPLEMENTOR FUNCTION
* -------- ----------- --------
* 17 July 2020 bzs Fixed storage of data in preservedInfo dynamic array
*
*/
*
Equ DROPBOX_SAVED_KEY$ To "DROPBOX_UPLOAD"
*
$Insert O4WCommon
$Insert O4WEquates
*
If Assigned(destn) Else destn = ""
If Assigned(ID) Else ID = ""
If Assigned(name) Else name = ""
If Assigned(StyleInfo) Else StyleInfo = ""
If Assigned(size) Else size = ""
If Assigned(origvalue) Else origvalue = ""
*
Declare Function rti_util_dropbox, rti_get_cfg
*
dropboxInfo = rti_get_cfg("CFG_DROPBOX")
* <1> URL for API request
* <2> access token
* <3> duration for link (optional)
* <4> folder for output (optional)
* <5> list of valid extensions (comma-delimited) (optional)
*
If dropboxinfo<1> = "" Or dropboxInfo<2> = "" Then Return
link = rti_util_dropbox("UPLOAD_LINK", origValue)
* parse new link and put into destn
destn = ""
If link <> "" Then
* success
* replace (or add) our special style
Locate "o4wfile" In styleInfo<1,1> using @SVM setting dummy Else null
styleInfo<1,1,dummy> = "o4wDropboxFile"
validExts = dropboxInfo<5>
If validExts <> "" Then
Convert @VM To "," In validExts ;* make sure we have the proper delimiter
acceptTypes = validExts
* so we have a list for example of jpg,jpeg,zip,bin
Swap "," With ",." In acceptTypes
* now the list is jpg,.jpeg,.zip,.bin
acceptTypes = ".":acceptTypes
styleInfo<1,1,-1> = o4wUploadBoxOptions("", acceptTypes)
Convert "," To "|" In validExts
o4wstore(validExts, id:"_dropbox_ext", id:"_dropbox_ext")
end
o4wstore(link, id:"_dropbox_url", id:"_dropbox_url")
Read preservedInfo From O4WTempFile%, O4WSessionId%:"*":DROPBOX_SAVED_KEY$ Else preservedInfo = ""
Locate id In preservedInfo<1> using @VM setting dummy Then
preservedInfo<2,dummy> = origValue
End Else
preservedInfo<1,-1> = id
preservedInfo<2,-1> = origValue
end
Write preservedInfo On O4WTempFile%, O4WSessionId%:"*":DROPBOX_SAVED_KEY$
o4wstore(DROPBOX_SAVED_KEY$, "o4wOtherUploads")
End
Return 0