TappNetwork / laravel-uppy-s3-multipart-upload

Multipart Uploads using Laravel, AWS S3, and Uppy
MIT License
69 stars 18 forks source link

It doesn't work with uppy v2 #5

Closed jtrod closed 3 years ago

jtrod commented 3 years ago

Uppy Companion V2, now handles, signature batching. Unfortunately I don't have time to contribute but I wish... This will solve your issue in your controller and make it Uppy 2 compatible:

public function prepareUploadPart(Request $request, $uploadId, $batch)
{
    $key = $this->encodeURIComponent($request->input('key'));

    $partNumbers = explode(",", $request->partNumbers);

    $urls = [];
    foreach ($partNumbers as $partNumber) {
        $command = $this->client->getCommand('uploadPart', [
            'Bucket'     => $this->bucket,
            'Key'        => $key,
            'UploadId'   => $uploadId,
            'PartNumber' =>  (int) $partNumber,
            'Body'       => '',
        ]);

        $urls[$partNumber] = (string) $this->client->createPresignedRequest($command, '+2 hour')->getUri();
    }

    return response()
        ->json([
            'presignedUrls' => $urls,
        ]);
}
unitidev commented 3 years ago

Uppy Companion V2, now handles, signature batching. Unfortunately I don't have time to contribute but I wish... This will solve your issue in your controller and make it Uppy 2 compatible:

public function prepareUploadPart(Request $request, $uploadId, $batch)
{
    $key = $this->encodeURIComponent($request->input('key'));

    $partNumbers = explode(",", $request->partNumbers);

    $urls = [];
    foreach ($partNumbers as $partNumber) {
        $command = $this->client->getCommand('uploadPart', [
            'Bucket'     => $this->bucket,
            'Key'        => $key,
            'UploadId'   => $uploadId,
            'PartNumber' =>  (int) $partNumber,
            'Body'       => '',
        ]);

        $urls[$partNumber] = (string) $this->client->createPresignedRequest($command, '+2 hour')->getUri();
    }

    return response()
        ->json([
            'presignedUrls' => $urls,
        ]);
}

You saved my life, Thank you. !!!

andreia commented 3 years ago

Thank you @jtrod ! Created a PR for it: https://github.com/TappNetwork/laravel-uppy-s3-multipart-upload/pull/6

jtrod commented 3 years ago

No, thanks to you for this nice package! 👍