@@ -114,7 +114,7 @@ public function getUsage(): OffloadUsage
114114 /**
115115 * Update the metadata of the image with the given ID.
116116 */
117- public function updateImageMetadata (string $ imageId , int $ fileSize = 0 , $ height = 'auto ' , $ width = 'auto ' ): void
117+ public function updateImageMetadata (string $ imageId , int $ fileSize = 0 , $ height = 'auto ' , $ width = 'auto ' , $ originalUrl = '' ): void
118118 {
119119 if ('auto ' !== $ height && !is_int ($ height )) {
120120 throw new InvalidArgumentException ('Image height must be "auto" or an integer. ' );
@@ -127,6 +127,7 @@ public function updateImageMetadata(string $imageId, int $fileSize = 0, $height
127127 'originalFileSize ' => $ fileSize ,
128128 'height ' => is_int ($ height ) ? max (0 , $ height ) : $ height ,
129129 'width ' => is_int ($ width ) ? max (0 , $ width ) : $ width ,
130+ 'originalUrl ' => $ originalUrl ,
130131 'updateDynamo ' => 'success ' ,
131132 ]);
132133 }
@@ -179,7 +180,7 @@ public function uploadImage(string $filename, string $imageUrl): string
179180 }
180181
181182 try {
182- $ this ->httpClient ->sendRequest ('put ' , $ uploadUrl , $ image , [
183+ $ this ->httpClient ->sendRequest ('PUT ' , $ uploadUrl , $ image , [
183184 'Content-Type ' => $ fileMimeType ,
184185 ]);
185186 } catch (BadResponseException $ exception ) {
@@ -188,7 +189,7 @@ public function uploadImage(string $filename, string $imageUrl): string
188189
189190 $ imagesize = getimagesize ($ filename );
190191
191- $ this ->updateImageMetadata ($ imageId , filesize ($ filename ) ?: 0 , $ imagesize && !empty ($ imagesize [1 ]) ? $ imagesize [1 ] : 'auto ' , $ imagesize && !empty ($ imagesize [0 ]) ? $ imagesize [0 ] : 'auto ' );
192+ $ this ->updateImageMetadata ($ imageId , filesize ($ filename ) ?: 0 , $ imagesize && !empty ($ imagesize [1 ]) ? $ imagesize [1 ] : 'auto ' , $ imagesize && !empty ($ imagesize [0 ]) ? $ imagesize [0 ] : 'auto ' , $ imageUrl );
192193
193194 return $ imageId ;
194195 }
@@ -237,8 +238,8 @@ private function getUploadApiCredentialsFromDashboardApi(): array
237238 */
238239 private function requestToDashboardApi (): array
239240 {
240- return $ this ->httpClient ->sendRequest ('post ' , sprintf ('%s/optml/v2/account/details ' , $ this ->options ['dashboard_api_url ' ]), null , [
241- 'Authorization ' => sprintf ('Bearer %s ' , $ this ->key ),
241+ return $ this ->httpClient ->sendRequest ('POST ' , sprintf ('%s/optml/v2/account/details ' , $ this ->options ['dashboard_api_url ' ]), null , [
242+ 'Authorization ' => sprintf ('Bearer %s ' , $ this ->options [ ' dashboard_api_key ' ] ),
242243 'Content-Type ' => 'application/json ' ,
243244 ]);
244245 }
@@ -252,7 +253,7 @@ private function requestToUploadApi(array $body): array
252253 $ this ->options ['upload_api_credentials ' ] = $ this ->getUploadApiCredentialsFromDashboardApi ();
253254 }
254255
255- return $ this ->httpClient ->sendRequest ('post ' , $ this ->options ['upload_api_url ' ], array_merge ($ this ->options ['upload_api_credentials ' ], $ body ), [
256+ return $ this ->httpClient ->sendRequest ('POST ' , $ this ->options ['upload_api_url ' ], array_merge ($ this ->options ['upload_api_credentials ' ], $ body ), [
256257 'Content-Type ' => 'application/json ' ,
257258 ]);
258259 }
0 commit comments