From 3064b44b92e8d0aff3a7d5b4b721d635ead7c5e9 Mon Sep 17 00:00:00 2001
From: Alexander Tkachev
Date: Sun, 10 Jul 2016 10:29:51 +0600
Subject: CLOUD: Switch to "multiple" files uploading
Still doesn't support directories uploading.
---
.../networking/sdl_net/uploadfileclienthandler.cpp | 29 ++++++++++++---------
backends/networking/wwwroot.zip | Bin 230989 -> 231000 bytes
backends/networking/wwwroot/.files.html | 2 +-
3 files changed, 17 insertions(+), 14 deletions(-)
(limited to 'backends')
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp
index 733a87b102..0ca5e3f684 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.cpp
+++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp
@@ -114,7 +114,7 @@ void UploadFileClientHandler::handleBlockHeaders(Client *client) {
Common::String headers = readEverythingFromMemoryStream(_headersStream);
Common::String fieldName = "";
readFromThatUntilDoubleQuote(headers.c_str(), "name=\"", fieldName);
- if (fieldName != "upload_file") return;
+ if (!fieldName.hasPrefix("upload_file[")) return;
Common::String filename = "";
readFromThatUntilDoubleQuote(headers.c_str(), "filename=\"", filename);
@@ -148,18 +148,21 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
// if previous block headers were file-related and created a stream
if (_contentStream) {
_contentStream->flush();
- // success - redirect back to directory listing
- HandlerUtils::setMessageHandler(*client,
- Common::String::format(
- "%s
%s",
- _("Uploaded successfully!"),
- client->queryParameter("path").c_str(),
- _("Back to parent directory")
- ),
- "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
- );
- _state = UFH_STOP;
- return;
+
+ if (client->noMoreContent()) {
+ // success - redirect back to directory listing
+ HandlerUtils::setMessageHandler(*client,
+ Common::String::format(
+ "%s
%s",
+ _("Uploaded successfully!"),
+ client->queryParameter("path").c_str(),
+ _("Back to parent directory")
+ ),
+ "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
+ );
+ _state = UFH_STOP;
+ return;
+ }
}
// if no file field was found, but no more content avaiable - failure
diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip
index 4dcb9b0dfd..ae19ef7d29 100644
Binary files a/backends/networking/wwwroot.zip and b/backends/networking/wwwroot.zip differ
diff --git a/backends/networking/wwwroot/.files.html b/backends/networking/wwwroot/.files.html
index d14acfcd36..c83a59f718 100644
--- a/backends/networking/wwwroot/.files.html
+++ b/backends/networking/wwwroot/.files.html
@@ -26,7 +26,7 @@
{upload_file_desc}