Permalink
Browse files

Changed generation of caddyfile

  • Loading branch information...
1 parent af8445f commit 03e5f63e5a19abc28fbe8dc2670b009288ae5f3b @ghecquet ghecquet committed Aug 25, 2016
@@ -517,7 +517,8 @@ public function generateCaddyFile($params) {
$hosts[$key] = array_merge(
(array)$hosts[$key],
[
- "pydioauth " . $path => [$authURL, $tokenURL . "&device=websocket"],
+ "pydioauth " . $path => [$tokenURL . "&device=websocket"],
+ "pydiopre " . $path => [$authURL],
"pydiows " . $path => []
]
);
@@ -528,7 +529,7 @@ public function generateCaddyFile($params) {
if ($active) {
- $authURL = $serverURL . "/api/{repo}/upload/put";
+ $authURL = $serverURL . "/api/{repo}/upload/put?xhr_uploader=true";
$host = $params["UPLOAD_HOST"];
$port = $params["UPLOAD_PORT"];
@@ -547,8 +548,16 @@ public function generateCaddyFile($params) {
"\t\tAccess-Control-Allow-Credentials true\n" .
"\t}"
],
- "pydioauth " . $path => [$authURL, $tokenURL . "&device=upload"],
- "pydioupload " . $path => []
+ "pydioauth " . $path => [$tokenURL . "&device=upload"],
+ "pydiopre " . $path => [$authURL, "{\n" .
+ "\t\theader X-File-Direct-Upload request-options\n" .
+ "\t}"
+ ],
+ "pydioupload " . $path => [],
+ "pydiopost " . $path => [$authURL, "{\n" .
+ "\t\theader X-File-Direct-Upload upload-finished\n" .
+ "\t}"
+ ],
]
);
}
@@ -110,10 +110,23 @@ public function preProcess(\Psr\Http\Message\ServerRequestInterface &$request, \
// Mandatory headers
$externalUploadStatus = $serverData['HTTP_X_FILE_DIRECT_UPLOAD'];
+ $fileNameH = $serverData['HTTP_X_FILE_NAME'];
+ $fileSizeH = (int)$serverData['HTTP_X_FILE_SIZE'];
+
+ // Faking data if not present
+ if (empty($fileNameH)) {
+ $fileNameH = "fake-name";
+ }
+
+ if (empty($fileSieH)) {
+ $fileSizeH = 1;
+ }
+
if(!ExternalUploadedFile::isValidStatus($externalUploadStatus)){
throw new PydioException("Unrecognized direct upload status ". $externalUploadStatus);
}
- $uploadedFile = new ExternalUploadedFile($externalUploadStatus, 1, "fake-name");
+
+ $uploadedFile = new ExternalUploadedFile($externalUploadStatus, $fileSizeH, $fileNameH);
} else {
@@ -765,6 +765,7 @@ Class.create("XHRUploader", {
uri = "http"+(this.configs.get("UPLOAD_SECURE")?"s":"")+"://"+this.configs.get("UPLOAD_HOST")+":"+this.configs.get("UPLOAD_PORT")+"/"+this.configs.get("UPLOAD_PATH")+"/"+pydio.user.activeRepository + currentDir;
}
+
var upload = xhr.upload;
upload.addEventListener("progress", function(e){
if (!e.lengthComputable) return;

0 comments on commit 03e5f63

Please sign in to comment.