@@ -114,7 +114,7 @@ public function getUsage(): OffloadUsage
114
114
/**
115
115
* Update the metadata of the image with the given ID.
116
116
*/
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
118
118
{
119
119
if ('auto ' !== $ height && !is_int ($ height )) {
120
120
throw new InvalidArgumentException ('Image height must be "auto" or an integer. ' );
@@ -127,6 +127,7 @@ public function updateImageMetadata(string $imageId, int $fileSize = 0, $height
127
127
'originalFileSize ' => $ fileSize ,
128
128
'height ' => is_int ($ height ) ? max (0 , $ height ) : $ height ,
129
129
'width ' => is_int ($ width ) ? max (0 , $ width ) : $ width ,
130
+ 'originalUrl ' => $ originalUrl ,
130
131
'updateDynamo ' => 'success ' ,
131
132
]);
132
133
}
@@ -179,7 +180,7 @@ public function uploadImage(string $filename, string $imageUrl): string
179
180
}
180
181
181
182
try {
182
- $ this ->httpClient ->sendRequest ('put ' , $ uploadUrl , $ image , [
183
+ $ this ->httpClient ->sendRequest ('PUT ' , $ uploadUrl , $ image , [
183
184
'Content-Type ' => $ fileMimeType ,
184
185
]);
185
186
} catch (BadResponseException $ exception ) {
@@ -188,7 +189,7 @@ public function uploadImage(string $filename, string $imageUrl): string
188
189
189
190
$ imagesize = getimagesize ($ filename );
190
191
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 );
192
193
193
194
return $ imageId ;
194
195
}
@@ -237,8 +238,8 @@ private function getUploadApiCredentialsFromDashboardApi(): array
237
238
*/
238
239
private function requestToDashboardApi (): array
239
240
{
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 ' ] ),
242
243
'Content-Type ' => 'application/json ' ,
243
244
]);
244
245
}
@@ -252,7 +253,7 @@ private function requestToUploadApi(array $body): array
252
253
$ this ->options ['upload_api_credentials ' ] = $ this ->getUploadApiCredentialsFromDashboardApi ();
253
254
}
254
255
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 ), [
256
257
'Content-Type ' => 'application/json ' ,
257
258
]);
258
259
}
0 commit comments