Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Pydio REST API Dateiupload mit Delphi (https://www.delphipraxis.net/188908-pydio-rest-api-dateiupload-mit-delphi.html)

3rad 19. Apr 2016 10:38

Pydio REST API Dateiupload mit Delphi
 
Hallo Zusammen,

ich versuche eine Datei auf einen Pydio-Server per REST-Api hochzuladen und bekomme die Fehlermeldung "Warning, missing headers!"
Die Quelle der Fehlermeldung hab ich mittlerweile gefunden.
Im Script class.SimpleUploadProcessor.php werden die PHP-Variablen
$_SERVER['HTTP_X_FILE_NAME']
$_SERVER['CONTENT_LENGTH']
geprüft. Und die Variable 'HTTP_X_FILE_NAME' ist nicht gesetzt. Wie kann ich die von Delphi aus setzen
Sämtlich versuche mit
Code:
 
  FoRESTRequest.AddParameter('HTTP_X_FILE_NAME', ExtractFileName(sDateinameLokal));
  FoRESTRequest.AddParameter('X_FILE_NAME', ExtractFileName(sDateinameLokal));
  FoRESTRequest.AddParameter('X-FILE-NAME', ExtractFileName(sDateinameLokal));
  FoRESTRequest.AddParameter('FILE_NAME', ExtractFileName(sDateinameLokal));
  FoRESTRequest.AddParameter('FILE-NAME', ExtractFileName(sDateinameLokal));
setzen die $_SERVER['HTTP_X_FILE_NAME'] Variable nicht.

Hier mein Delphi Code für den Upload:
Code:
  FoRESTRequest.Params.Clear;
  FoRESTRequest.ClearBody;
  FoRESTRequest.Method := TRESTRequestMethod.rmPUT;
  if bAutoRename then
    FoRESTRequest.AddParameter('auto_rename', 'true');
  FoRESTRequest.AddParameter('input_upload', 'false');
  FoRESTRequest.AddParameter('urlencoded_filename', ExtractFileName(sDateinameLokal));
  FoRESTRequest.Resource := Format('%s/upload/input_stream/%s', [S_PydioWorkSpace, sVerzeichnisRemote]);



  oFileStream := TFileStream.Create(sDateinameLokal, fmOpenRead);
  try
    oFileStream.Position := 0;
    FoRestRequest.AddBody(oFileStream, TRESTContentType.ctAPPLICATION_OCTET_STREAM);
    FoRESTRequest.Execute;
    if FoRESTResponse.Status.Success then
    begin
       .
       .
    end
FoRESTResponse.Status.Success aber liefert TRUE zurück und der Request wird auch ausgeführt. Es kommt nur nichts auf dem Server an.

Hier ein Ausschnitt der Serverseite aus class.SimpleUploadProcessor.php:
Code:
   
public function preProcess($action, &$httpVars, &$fileVars)
    {
        if (!isSet($httpVars["input_stream"]) || isSet($httpVars["force_post"])) {
            return false;
        }
      
        $headersCheck = isset(
                $_SERVER['CONTENT_LENGTH'],
                $_SERVER['HTTP_X_FILE_NAME']
            ) ;
        if (isSet($_SERVER['HTTP_X_FILE_SIZE'])) {
            if ($_SERVER['CONTENT_LENGTH'] != $_SERVER['HTTP_X_FILE_SIZE']) {
                exit('Warning, wrong headers');
            }
        }
        $fileNameH = $_SERVER['HTTP_X_FILE_NAME'];
        $fileSizeH = $_SERVER['CONTENT_LENGTH'];

        if (dirname($httpVars["dir"]) == "/" && basename($httpVars["dir"]) == $fileNameH) {
            $httpVars["dir"] = "/";
        }
        $this->logDebug("SimpleUpload::preProcess", $httpVars);

        if ($headersCheck) {
            // create the object and assign property
            $fileVars["userfile_0"] = array(
                "input_upload" => true,
                "name"        => SystemTextEncoding::fromUTF8(basename($fileNameH)),
                "size"        => $fileSizeH
            );
        } else {
            exit("Warning, missing headers!");
        }
    }
Infos zum Pydio REST Api sind hier
https://pydio.com/en/docs/references...s/upload_put_3


Habt Ihr eine Idee, was ich tun muss, damit die Server-Variable $_SERVER['HTTP_X_FILE_NAME'] gesetzt wird und die die Datei hochgeladen wird?
Viele Dank schon mal.

Viele Grüße
Andreas


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:09 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz