March 28, 2024

Alfresco tips and tricks – #8 FTP upload from command line using CURL

Here is a tip useful for systems with no GUI. To upload/download files to/from Alfresco you can use a FTP command line tool like curl. Follows the Alfresco FTP Server configuration in the alfresco-global.properties file.

### FTP Server Configuration ###
ftp.enabled=true
ftp.port=2121

# The default root path for FTP Server
protocols.rootPath=/${spaces.company_home.childname}
filesystem.rootPath=${protocols.rootPath}

# Possible values for the FTP debugging:
# STATE, RXDATA, TXDATA, DUMPDATA, SEARCH, INFO, FILE, FILEIO,
# ERROR, PKTTYPE, TIMING, DATAPORT, DIRECTORY, SSL
ftp.sessionDebug=

 

$ curl -v -T test-file.txt ftp://admin:admin@localhost:2121/Alfresco/

giuseppe-urso-alfresco-ftp-with-curl-02

giuseppe-urso-alfresco-ftp-with-curl-01

9 Comments

  1. Giuseppe Urso

    1. USING THE PASSWORD PROMPT:
    > curl -u “admin” -v -T test.txt ftp://localhost:2121/Alfresco/

    2. USING A PLAIN TEXT FILE
    > cat password.txt | sed ‘s/^/user=”admin:/;s/$/\”/’ | curl -K – -v -T test.txt ftp://localhost:2121/Alfresco/

    3. USING FTP CLIENT
    > ftp localhost 2121

    NOTE: Use the “-K” option to tell curl to read parameters from a file or stdin to which you can pass the secret info.
    In every case always remember that FTP is not a secure protocol. FTP passwords are sent in clear across the network therefore a MITM attack can easly steals the user’s credentials. 

    Reply
  2. Tjarda Peelen

    Thank you very much! (Altough it is a catagory RTFM… sorry or that…) Thanks for your Tips’n’Tricks!

    Reply
  3. Armando

    Hi,

    Thanks so much for your great blog!

    I have a question, Can I use SFTP instead of FTP?

    Reply
  4. Armando

    How Can I Define the path, for example I have three sites named, “IT, Networking, Security” and I want to send files to these sites. How can I define or where can I look what is the path to do it in command line?

    Thanks

    Reply
    1. Giuseppe

      Use a common FTP client like Filezilla to access Alfresco and browse the repository. Site documents are located here: /alfresco/sites//documentLibrary

  5. Armando

    Hi Giuseppe,

    Thanks for your help.

    I could not find the sites via command line, Do you know the exact location? Please look my path of installation and there does not exist.
    Do you have any idea?

    Image: http://prntscr.com/jzs3xm

    Thanks so much.

    Reply
    1. Giuseppe

      Pay attention: path you are looking for has nothing to do with the alfresco installation. Forget the installation path on your disk and try first to browse the alfresco repository via Filezilla. After you logged in, you will easly browse the alfresco repository.
      If you don’t want to use Filezilla, open your browser and go to something like

      http://localhost:8080/share/page/repository

Leave a Reply to Armando Cancel Reply

Your email address will not be published.