Accessing FTP with UCB

Creating a macro - Writing a Script - Using the API

Accessing FTP with UCB

Postby JulianR » Mon Jul 01, 2019 10:47 am

Hi!

I have been making some experiments with FTP and BASIC macros. So far I have confirmed, that uploading and downloading files with simple file access is possible, but folder creation fails (the user account can use other clients to crate folders on ftp server).
So I have tried to make use of FTPContentProvider. But I can't figure out how to use it.

So far I have managed to get to:
Code: Select all   Expand viewCollapse view
dim ftpContPro, ftpCont, ucb, ftpContId, newCont, test
Dim oContInfo As New com.sun.star.ucb.ContentInfo
Dim command As New  com.sun.star.ucb.Command
Dim openCom As New com.sun.star.ucb.OpenCommandArgument2
ftpContPro = CreateUnoService("com.sun.star.ucb.FTPContentProvider")
ucb = CreateUnoService("com.sun.star.ucb.UniversalContentBroker")
ftpContId = ucb.createContentIdentifier("ftp://ftptest:test@127.0.0.1")
ftpCont = ftpContPro.queryContent(ftpContId)
command.Handle = -1
command.Name = "getCommandInfo"
test = ftpCont.execute(command, ftpCont.createCommandIdentifier(), null)

But when I have tried to create new content to use with open command
Code: Select all   Expand viewCollapse view
oContInfo.Type = "application/vnd.sun.staroffice.ftp-box"
newCont = ftpCont.createNewContent(oContInfo)

then xray says that the new content object is null. And now I am out of ideas.

Can anyone help with this?
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am

Re: Accessing FTP with UCB

Postby Villeroy » Mon Jul 01, 2019 12:23 pm

You can use Python as a full featutured alternative macro language.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27246
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Accessing FTP with UCB

Postby JulianR » Mon Jul 01, 2019 1:54 pm

I lack experience with Python (I wrote one small and very limited DB backend program in it so far). And Basic has an IDE which works out of the box. I have looked at both Python and Java, and both look like a lot of work just to setup development environment.

Also I just tried to use pip with python bundled with LO installation, but I failed. Can I use pip to import libraries in LO on Windows? I have seen some people having similar problems on Windows.

FTPlib seems to be available, so at least for this project it would work.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am

Re: Accessing FTP with UCB

Postby hubert lambert » Sat Jul 06, 2019 2:55 pm

Hi,

Have you seen this page, and tried the examples it contains: https://www.openoffice.org/ucb/docs/ucp ... p-ucp.html ?
Regards.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 132
Joined: Mon Jun 13, 2016 10:50 am

Re: Accessing FTP with UCB

Postby JulianR » Mon Jul 08, 2019 12:25 pm

Hi!

I have seen that page earlier, there are no examples in the document. I can't find examples in BASIC on how to use this feature.
I am not even sure if I could follow the docs with java examples, they are written in a very brief style and I have trouble translating JAVA code into BASIC.
Anyway, I just need a way to create folders on remote server, so I will most likely end up using python for that functionality.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
JulianR
 
Posts: 25
Joined: Mon Mar 12, 2018 9:41 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests