Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Upload Chunk Incorrect Regex and PHPDocs #31

Open
patrickeaton opened this issue Nov 13, 2018 · 1 comment
Open

Upload Chunk Incorrect Regex and PHPDocs #31

patrickeaton opened this issue Nov 13, 2018 · 1 comment

Comments

@patrickeaton
Copy link

The Upload Chunk Function in autodesk/forge-client/lib/Api/ObjectsAPI.php:1097 claims the body is SplFileObject where it's actually expecting a string.

Also there is an error with the Regex at autodesk/forge-client/lib/Api/ObjectsApi.php:1147
The forward slash between the range and size is not correctly escaped it should look like

"/^bytes [0-9]+\\-[0-9]+\\/[0-9]+$/"

@bentudman
Copy link

bentudman commented Dec 6, 2018

I agree, I rewrote autodesk/forge-client/lib/Api/ObjectsApi.php:1147 as below

if (!preg_match("/^bytes [0-9]+-[0-9]+\/[0-9]+$/", $content_range)) {

Additionally (less of an error, more of a use case), I amended autodesk/forge-client/lib/ApiClient.php:194 from

} elseif ($method === self::$PUT) {
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($curl, CURLOPT_POSTFIELDS, file_get_contents($postData));

to

} elseif ($method === self::$PUT) {
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
  if ($endpointPath === '/oss/v2/buckets/{bucketKey}/objects/{objectName}/resumable') {
    $put = $postData;
  } else {
    $put = file_get_contents($postData);
  }
  curl_setopt($curl, CURLOPT_POSTFIELDS, $put);

Coded this way to tie into my use case of

$file = new SplFileObject($path);
...
$result = $apiInstance->uploadChunk($bucket_key, $file->getFilename(), $length, $range, $sessionId, $file->fread($length));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants