Using external automated means for creating a weblink

Please post here if you have problems in using Wing FTP Server.

Using external automated means for creating a weblink

Postby robjager » Fri Oct 01, 2021 2:02 pm

Hello,

I am in need of a way to automate the creation of a weblink...now we give an URL with userid and password by email to the recipient, but want to make this more secure.

We have Wing-ftp corp ed.(latest) and Our IBM i-series drops a file in the ftp customer directory, sends out the email with a link to the file that includes a user and password in plain text.

--> How do I create a weblink externally; I saw the bookmark_db file that contains the 32-chr files that make up the weblinks, but can't seem to recreate them from an external script. We tried the powershell that was available on the forum, but that didn't work. Do we need to use the MySQL option?

Preale some advice!
robjager
 
6
 
Wed Sep 29, 2021 10:53 am

Re: Using external automated means for creating a weblink

Postby FTP » Tue Oct 12, 2021 4:44 am

OK, you can generate a weblink for the uploaded file automatically by the event "OnFileUploaded -> Lua Script":

Code: Select all
local domain = "%Domain"
local user = "%Name"
local filepath = string.gsub("%PathName", "\\","/")
local filename = "%FileName"
local filesize = "%FileSize"

local weblink = md5(domain..user..filepath..c_GetGlobalOptionStr(GOPTION_START_TIME_STR))
local fp = assert(io.open(c_GetAppPath().."/Data/_WEBLINK/"..weblink, "wb"))
fp:write(filepath.."\r\n-1\r\n-1")
fp:close()

local sql = "insert into wftp_weblink values (NULL, '"..weblink.."', '"..domain.."', '"..user.."', 0, datetime(CURRENT_TIMESTAMP,'localtime'), datetime(CURRENT_TIMESTAMP,'localtime'), 0, '"..filename.."', '"..filepath.."', "..filesize..", '', '',-1)"
c_ExecuteSQL(sql)
FTP
Site Admin
 
1869
 
Tue Sep 29, 2009 6:09 am

Re: Using external automated means for creating a weblink

Postby robjager » Fri Oct 15, 2021 8:44 am

ThanX !

It works almost....

1 issue left only:

if I generate an MD5 of the file name only, it differs from the MD5 I get when using the windows certutil -hashfile [file] MD5 option!

That would make it easier to generate a link SEPARATELY from the wingftp database, but still use the buildin weblink generator.
robjager
 
6
 
Wed Sep 29, 2021 10:53 am

Re: Using external automated means for creating a weblink

Postby robjager » Fri Oct 15, 2021 9:30 am

Is it possible to get the MD5 hash from the file? that would solve my problem.
robjager
 
6
 
Wed Sep 29, 2021 10:53 am

Re: Using external automated means for creating a weblink

Postby FTP » Fri Oct 15, 2021 12:51 pm

Sorry, the parameter for the Lua API "md5" is a string, not a filename or a file handle.
FTP
Site Admin
 
1869
 
Tue Sep 29, 2009 6:09 am

Re: Using external automated means for creating a weblink

Postby robjager » Tue Oct 26, 2021 12:30 pm

Thnx,

I wanted to know as I need a means to generate the filename from some string. And an external app has to do this.

So... Can an external app write in the sql file wftp_weblink ???
robjager
 
6
 
Wed Sep 29, 2021 10:53 am

Re: Using external automated means for creating a weblink

Postby FTP » Tue Oct 26, 2021 1:26 pm

OK, wftp_weblink is the table name, the database file is "Data/bookmark_db", its a SQLite database, of course you can access that database via external app.
FTP
Site Admin
 
1869
 
Tue Sep 29, 2009 6:09 am

Re: Using external automated means for creating a weblink

Postby robjager » Wed Oct 27, 2021 6:15 am

thank you! I will try this immediately.


i'll let you know if it functions.
robjager
 
6
 
Wed Sep 29, 2021 10:53 am

Re: Using external automated means for creating a weblink

Postby robjager » Wed Oct 27, 2021 12:14 pm

It Worked. (using powershell)

Small gripe.... the bookmark_db is locked while using Powershell, so changes won't reflect immediately in the admin console.


Thanks for your assistance ( we're planning an extra 5 ftp corp licenses for next month)
robjager
 
6
 
Wed Sep 29, 2021 10:53 am


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests