Created
August 13, 2024 16:08
-
-
Save soyuka/f52aa1a14f86bdf5c55767f5c686a7ba to your computer and use it in GitHub Desktop.
Revisions
-
soyuka created this gist
Aug 13, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ $uploadSession = $this->metaClient->request('POST', sprintf('%s/uploads', $this->metaAppId), [ 'query' => [ 'file_name' => $mediaObject->getFilePath(), 'file_length' => $mediaObject->getContentSize(), 'file_type' => $mediaObject->getMimeType(), 'access_token' => $credential->getAccessToken(), 'appsecret_proof' => $this->secretProof($credential->getAccessToken()), ], ])->toArray(); if (!isset($uploadSession['id'])) { throw new BroadcastServiceProviderException('Error while creating upload session'); } $handle = $this->metaClient->request('POST', '/' . $uploadSession['id'], [ // / is important see https://github.com/symfony/symfony/issues/54332 'headers' => [ 'file_offset' => '0', 'content-length' => $mediaObject->getContentSize(), ], 'body' => $this->mediaStorage->readStream($mediaObject->getFilePath()), 'query' => [ 'access_token' => $credential->getAccessToken(), 'appsecret_proof' => $this->secretProof($credential->getAccessToken()), ], ])->toArray(); return $handle['h']; }