From 535b682124ec292f4654f8a62fbef26c3fd8c06a Mon Sep 17 00:00:00 2001 From: Giorgos Giakoumettis Date: Mon, 29 Oct 2018 21:51:46 +0200 Subject: [PATCH] Adding fileInfo support on upload According to the b2_upload_file spec we need to parse up to Up to 10 of these headers to be converted from into json key value pairs. --- src/Client.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index 55bbfd6..d332324 100644 --- a/src/Client.php +++ b/src/Client.php @@ -204,8 +204,8 @@ public function upload(array $options) if (!isset($options['FileContentType'])) { $options['FileContentType'] = 'b2/x-auto'; } - - $response = $this->client->request('POST', $uploadEndpoint, [ + + $body = [ 'headers' => [ 'Authorization' => $uploadAuthToken, 'Content-Type' => $options['FileContentType'], @@ -215,7 +215,15 @@ public function upload(array $options) 'X-Bz-Info-src_last_modified_millis' => $options['FileLastModified'] ], 'body' => $options['Body'] - ]); + ]; + + if (isset($options['FileInfo']) && is_array($options['FileInfo'])) { + foreach($options['FileInfo'] as $key => $value) { + $body['headers']["X-Bz-Info-{$key}"] = $value; + } + } + + $response = $this->client->request('POST', $uploadEndpoint, $body); return new File( $response['fileId'],