mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-16 10:05:56 +08:00
Add subdir support and device support in command line upload
This commit is contained in:
parent
2a1cc822ca
commit
6371c6cd50
@ -22,7 +22,7 @@
|
|||||||
#define _VERSION_ESP3D_H
|
#define _VERSION_ESP3D_H
|
||||||
|
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "3.0.0.a82"
|
#define FW_VERSION "3.0.0.a83"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
|
||||||
|
|
||||||
#endif //_VERSION_ESP3D_H
|
#endif //_VERSION_ESP3D_H
|
||||||
|
@ -53,6 +53,14 @@ void HTTP_Server::SDFileupload ()
|
|||||||
} else {
|
} else {
|
||||||
filename = upload.filename;
|
filename = upload.filename;
|
||||||
}
|
}
|
||||||
|
if (_webserver->hasArg ("rpath") ) {
|
||||||
|
upload_filename = _webserver->arg ("rpath") + filename;
|
||||||
|
if (upload_filename[0] != '/') {
|
||||||
|
filename = "/" + upload_filename;
|
||||||
|
} else {
|
||||||
|
filename = upload_filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
//Sanity check
|
//Sanity check
|
||||||
if (ESP_SD::exists (filename.c_str()) ) {
|
if (ESP_SD::exists (filename.c_str()) ) {
|
||||||
ESP_SD::remove (filename.c_str());
|
ESP_SD::remove (filename.c_str());
|
||||||
|
@ -52,6 +52,14 @@ void HTTP_Server::FSFileupload ()
|
|||||||
} else {
|
} else {
|
||||||
filename = upload.filename;
|
filename = upload.filename;
|
||||||
}
|
}
|
||||||
|
if (_webserver->hasArg ("rpath") ) {
|
||||||
|
upload_filename = _webserver->arg ("rpath") + filename;
|
||||||
|
if (upload_filename[0] != '/') {
|
||||||
|
filename = "/" + upload_filename;
|
||||||
|
} else {
|
||||||
|
filename = upload_filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
//Sanity check
|
//Sanity check
|
||||||
if (ESP_FileSystem::exists (filename.c_str()) ) {
|
if (ESP_FileSystem::exists (filename.c_str()) ) {
|
||||||
ESP_FileSystem::remove (filename.c_str());
|
ESP_FileSystem::remove (filename.c_str());
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#endif //ARDUINO_ARCH_ESP8266
|
#endif //ARDUINO_ARCH_ESP8266
|
||||||
#include "../../mks/mks_service.h"
|
#include "../../mks/mks_service.h"
|
||||||
#include "../../authentication/authentication_service.h"
|
#include "../../authentication/authentication_service.h"
|
||||||
|
|
||||||
//MKS files uploader handle
|
//MKS files uploader handle
|
||||||
void HTTP_Server::MKSFileupload ()
|
void HTTP_Server::MKSFileupload ()
|
||||||
{
|
{
|
||||||
@ -50,10 +51,33 @@ void HTTP_Server::MKSFileupload ()
|
|||||||
String filename = upload.filename;
|
String filename = upload.filename;
|
||||||
String sfilename = "s"+filename;
|
String sfilename = "s"+filename;
|
||||||
//No / in filename
|
//No / in filename
|
||||||
int p = filename.lastIndexOf("/");
|
if (filename[0]=='/') {
|
||||||
|
filename.remove(0,1);
|
||||||
|
}
|
||||||
|
//for remote path or device
|
||||||
|
//if USB on TFT 0:<path>
|
||||||
|
//if SD on TFT 1:<path>
|
||||||
|
//if SD on Robin 0:<path> or just <path>
|
||||||
|
|
||||||
if(p!=-1) {
|
if (_webserver->hasArg ("rpath") ) {
|
||||||
filename.remove(0,p+1);
|
String upload_filename = _webserver->arg ("rpath") + "/" + filename;
|
||||||
|
filename = upload_filename;
|
||||||
|
if (filename[0]=='/') {
|
||||||
|
filename.remove(0,1);
|
||||||
|
}
|
||||||
|
//this is target device
|
||||||
|
if (filename.startsWith("USB:") || filename.startsWith("SD:")) {
|
||||||
|
String cmd = "M998 ";
|
||||||
|
if (filename.startsWith("USB:")) {
|
||||||
|
cmd += "0";
|
||||||
|
filename.remove(0,strlen("USB:"));
|
||||||
|
} else {
|
||||||
|
cmd += "1";
|
||||||
|
filename.remove(0,strlen("SD:"));
|
||||||
|
}
|
||||||
|
MKSService::sendGcodeFrame(cmd.c_str());
|
||||||
|
Hal::wait(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_webserver->hasArg(sfilename)) {
|
if (_webserver->hasArg(sfilename)) {
|
||||||
fileSize = _webserver->arg(sfilename).toInt();
|
fileSize = _webserver->arg(sfilename).toInt();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user