2.7. Transferring files¶
ESPresso uses NodeMCU file module to write and read files from SPIFFS and operates on an object model. Following file objects (handles) are utilized:
espresso_dest
for uploading files,espresso_src
for downloading files.
Handles are freed as soon as transfer finishes.
If your ESP application also uses object model for file operations then ESPresso won’t affect your code at all.
Note
Ending transfer (and therefore closing file in the object model) will also close a file opened in the basic model. If your ESP application uses basic file model consider switching to newer and more robust object approach.
2.7.1. Uploading to ESP¶
Select file you want to send in the local (left) panel and hit:
- Upload [F5] - to upload with original filename,
- Upload as… [F6] - to upload with new filename. You may specify new filename of uploaded file in the dialog box. By default original filename with suffix _copy is suggested (i.e. init.lua → init_copy.lua).
Note
Please note that if a file with the same name exists on the ESP (remote) side it will be overwritten without a warning!
It’s possible to enable on-the-fly LuaSrcDiet source files compression using Diet switch. See LuaSrcDiet for more details.
Note
LuaSrcDiet processes only *.lua
(Lua source) files. The Diet switch may stay on if you transfer
other data (i.e. *.lc
Lua compiled files). ESPresso simply won’t pass them through LuaSrcDiet during transfer.
Note
Inactive Diet switch after ESP connection is established means that configuration is incomplete (please refer LuaSrcDiet chapter).
While uploading ESPresso by default uses binary data transfer that creates 100% carbon copy of the file on the ESP side. It is however still possible to enable old deprecated ASCII transfer mode. Please see INI file entries for more details.
2.7.2. Downloading from ESP¶
Select file you want to receive in the remote (right) panel and hit:
- Download - to download file with original filename,
- Download as… - to download with new filename. You may specify new filename of downloaded file in the dialog box. By default original filename with suffix _copy is suggested (i.e. init.lua → init_copy.lua).
Downloaded file is placed inside the directory of the left (local) panel.
If downloaded file exists on the local side a dialog box appears allowing you to choose from several options:
Overwrite - overwrite file on the local side,
Warning
Be careful when downloading back and overwriting
*.lua
files that have been compressed on the fly while uploading using LuaSrcDiet. Compressed Lua scripts may be difficult to interpret by a human and are stripped of any comments. Don’t loose your human-readable sources.Rename… - download file with new (unique) name - you will be asked to enter new filename,
Resume (available only if there is a local file with the same name, smaller than the ESP counterpart) - resume transfer and finish downloading,
Note
Please note that resuming doesn’t check at all if the part already present at the local side matches the part at ESP.
Cancel - cancel download.
While downloading ESPresso uses binary data transfer that creates 100% carbon copy of the file from the ESP.