Upload files?



  • Is there any way to upload a file, or possibly write data to an existing file, using '/file/:file'? When using php I can get a files contents by doing:

    $cURL = curl_init();
    
    curl_setopt($cURL, CURLOPT_URL, 'https://URL:5656/server/file/world/playerdata/TEST/test.txt');
    curl_setopt($cURL, CURLOPT_CAINFO, getcwd()."\certs\https.pem"); /*Trusting a local copy of the self-signed cert*/
    curl_setopt($cURL, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($cURL, CURLOPT_HTTPHEADER, [
      		"X-Access-Server: $XAccessServer",
      		"X-Access-Token: $XAccessToken",
     	]
    );
    $data = curl_exec($cURL);
    curl_close($cURL);
    

    and it outputs the contents, which is just "test". When using the code:

    $cURL = curl_init();
    
    curl_setopt($cURL, CURLOPT_URL, 'https://URL:5656/server/file/world/playerdata/TEST/test2.txt');
    curl_setopt($cURL, CURLOPT_CAINFO, getcwd()."\certs\https.pem"); /*Trusting a local copy of the self-signed cert*/
    curl_setopt($cURL, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($cURL, CURLOPT_HTTPHEADER, [
      		"X-Access-Server: $XAccessServer",
      		"X-Access-Token: $XAccessToken",
     	]
    );
    $data = curl_exec($cURL);
    curl_close($cURL);
    

    it creates a file called "test2.txt" and its contents are "undefined". The page http://scales.pufferpanel.com/docs/serverfilefile doesnt mention being able to do this, so im curious if its possible.



  • It is definitely possible but I believe this is not working for you because you're not putting any data into the file, so the PUT request is just creating a blank file with no contents.



  • @puffrfish and how would I go about putting the data into the file? I tried using a GET and then using that contents, but it didn't work.



  • This is sort of beyond the scope of this forum, but essentially you need to set more curl options (for example CURLOPT_INFILE) to load in the file data to be sent along with the request.



  • I will say though that I don't know if this even works and may be the reason it is not documented, as the panel itself does not upload files via PUT, it uses the websocket connection to upload directly from the browser.


Log in to reply
 

Looks like your connection to PufferPanel Community was lost, please wait while we try to reconnect.