Skip to content

CopyFile

Craig edited this page Jan 1, 2024 · 7 revisions

How To Use

<?php

use TechKat\BackBlazeB2\Client;

$keyID = '...';
$applicationKey = '...';

$client = new Client($keyID, $applicationKey);

$response = $client->copyFile([
  'sourceFileId' => '4_za71f544e781e6891531b001a_f200ec353a2184825_d20160409_m004829_c000_v0001016_t0028',
  'destinationBucketId' => 'BUCKET_ID',
  'fileName' => 'a_file_name.ext',
]);

return $response;

Expected Result

{
  "accountId": "YOUR_ACCOUNT_ID",
  "action": "copy",
  "bucketId": "BUCKET_ID",
  "contentLength": 123456789,
  "contentSha1": "c604542967a93466d4ed087956753161cfab3f31",
  "contentMd5": "dc724af18fbdd4e59189f5fe768a5f8311527050",
  "contentType": "type/format",
  "fileId": "4_zabcd123456efghijk7890_f123ab456a7890123_d20240101_m004829_c000_v0001016_t0028",
  "fileName": "a_file_name.ext",
  // ...
}

Backblaze B2 API Documentation

https://www.backblaze.com/apidocs/b2-copy-file