AI resources
Uploading a file
Using the terminal, you can upload a file via SFTP Console or SFTP batch scripting. SFTP Console is suitable for manual use but not for automations. For automations, use SFTP batch scripting, which requires the creation of a script where each line represents an SFTP command.
We recommend avoiding uploading files with the same name, as this could trigger a reprocessing. As a best practice, and to facilitate the identification of input and output files, it is suggested to add a timestamp at the end of the file name.
SFTP console
Using the code below as an example, follow the steps to upload a file using the SFTP console.
terminalUY0FVFGW103Q05P: ~ user$ sftp pg_sap@sftp-qa.mercadolibre.io Connected to sftp-mercadolibre.io. sftp> ls selfserviceinput selfserviceoutput sftp> cd selfserviceinput sftp> ls sftp> put / Users/user/debt_589_6_20230804.csv Uploading /Users/user/debt_589_6_20230804.csv to /selfserviceinput/debt_589_6_20230804.csv /Users/user/debt_589_6_20230804.csv sftp> ls debt_589_6_20230804.csv sftp> bye
- Log in to SFTP to open the SFTP console, as indicated in line 1 of the code.
- Access the 'selfserviceinput' folder, as indicated in line 5 of the code.
- List the contents with the
lscommand, as indicated in line 6 of the code (optional, only for review before uploading a file). - Upload the file using the command
put ${absolutePathFileName}, as indicated in line 7 of the code, which can be the relative path. - Verify that it has been uploaded, as indicated in line 10 of the code.
- Exit the SFTP console, as indicated in line 12.
SFTP batch scripting
The commands from the previous example in the console, for batch scripting, would be as follows:
terminalls cd selfserviceinput put /Users/user/debt_589_6_20230804.csv ls bye
The SFTP script is executed with the following command, where batch_script_file_name is the name of the file with the SFTP commands.
plainshell> sftp -b batch_script_file_name username@sftp.mercadolibre.io
Note
In this example, the default name and directory are used when generating the
ssh-rsa key. Otherwise, the -i parameter should be used.This is the result of the batch execution:
terminalUY0FVGW103Q0SP: ~ user$ sftp -b upload_sftp_script pg_sap@sftp-qa.mercadolibre.io sftp> ls selfserviceinput selfserviceoutput sftp> cd selfserviceinput sftp> put /Users/user/debt_589_6_20230804.csv sftp> ls debt_589_6_20230804.csv sftp> bye UY0FVFGW103Q05P:~ user$