Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Uploaded file
Browse files Browse the repository at this point in the history
  • Loading branch information
ghecquet committed Sep 22, 2016
1 parent 4a64194 commit e272eb5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion core/src/core/src/pydio/Core/Http/Wopi/AuthFrontend.php
Expand Up @@ -25,9 +25,9 @@
use Psr\Http\Message\ServerRequestInterface;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\ApiKeysService;
use Pydio\Core\Services\AuthService;
use Pydio\Auth\Frontend\Core\AbstractAuthFrontend;
use Pydio\Conf\Sql\SqlConfDriver;
use Zend\Diactoros\UploadedFile;

defined('AJXP_EXEC') or die('Access not allowed');

Expand Down Expand Up @@ -57,7 +57,12 @@ function detectVar(&$httpVars, $varName)
}

function retrieveParams(ServerRequestInterface &$request, ResponseInterface &$response) {

/** @var ContextInterface $context */
$action = $request->getAttribute("action");

$httpVars = $request->getParsedBody();

$jwt = $this->detectVar($httpVars, "access_token");
if (empty($jwt)) {
return false;
Expand All @@ -76,6 +81,20 @@ function retrieveParams(ServerRequestInterface &$request, ResponseInterface &$re

$_SERVER["REQUEST_URI"] = $uri->getPath() . '?' . $uri->getQuery();

// Handle upload case
if ($action == "upload") {
$stream = $request->getBody();

$uploadedFile = new UploadedFile(
$stream,
(int)$request->getHeader("content-length"),
0,
basename($path)
);

$request = $request->withUploadedFiles(["userfile_0" => $uploadedFile]);
}

$request = $request
->withUri($uri)
->withParsedBody($httpVars);
Expand Down

0 comments on commit e272eb5

Please sign in to comment.