Accessing FTP with UCB

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Accessing FTP with UCB

Post by JulianR »

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

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

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
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Accessing FTP with UCB

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: Accessing FTP with UCB

Post by JulianR »

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
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Accessing FTP with UCB

Post by hubert lambert »

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
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: Accessing FTP with UCB

Post by JulianR »

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
Post Reply