-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ramesh Mhetre <[email protected]>
- Loading branch information
1 parent
6fdb1ba
commit 3e68420
Showing
44 changed files
with
11,969 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/vendor | ||
composer.lock |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: php | ||
|
||
php: | ||
- '5.6' | ||
- '7.0' | ||
- '7.1' | ||
- nightly | ||
|
||
before_script: composer install |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
## Backblaze B2 for PHP | ||
|
||
`backblaze-b2` is a client library for working with Backblaze's B2 storage service. It aims to make using the service as | ||
easy as possible by exposing a clear API and taking influence from other SDKs that you may be familiar with. | ||
|
||
## Example | ||
|
||
This is just a short example, full examples to come on the wiki. | ||
|
||
```php | ||
use BackblazeB2\Client; | ||
use BackblazeB2\Bucket; | ||
|
||
$client = new Client('accountId', 'applicationKey'); | ||
|
||
// Returns a Bucket object. | ||
$bucket = $client->createBucket([ | ||
'BucketName' => 'my-special-bucket', | ||
'BucketType' => Bucket::TYPE_PRIVATE // or TYPE_PUBLIC | ||
]); | ||
|
||
// Change the bucket to private. Also returns a Bucket object. | ||
$updatedBucket = $client->updateBucket([ | ||
'BucketId' => $bucket->getId(), | ||
'BucketType' => Bucket::TYPE_PUBLIC | ||
]); | ||
|
||
// Retrieve an array of Bucket objects on your account. | ||
$buckets = $client->listBuckets(); | ||
|
||
// Delete a bucket. | ||
$client->deleteBucket([ | ||
'BucketId' => '4c2b957661da9c825f465e1b' | ||
]); | ||
|
||
// Upload a file to a bucket. Returns a File object. | ||
$file = $client->upload([ | ||
'BucketName' => 'my-special-bucket', | ||
'FileName' => 'path/to/upload/to', | ||
'Body' => 'I am the file content' | ||
|
||
// The file content can also be provided via a resource. | ||
// 'Body' => fopen('/path/to/input', 'r') | ||
]); | ||
|
||
// Download a file from a bucket. Returns the file content. | ||
$fileContent = $client->download([ | ||
'FileId' => $file->getId() | ||
|
||
// Can also identify the file via bucket and path: | ||
// 'BucketName' => 'my-special-bucket', | ||
// 'FileName' => 'path/to/file' | ||
|
||
// Can also save directly to a location on disk. This will cause download() to not return file content. | ||
// 'SaveAs' => '/path/to/save/location' | ||
]); | ||
|
||
// Delete a file from a bucket. Returns true or false. | ||
$fileDelete = $client->deleteFile([ | ||
'FileId' => $file->getId() | ||
|
||
// Can also identify the file via bucket and path: | ||
// 'BucketName' => 'my-special-bucket', | ||
// 'FileName' => 'path/to/file' | ||
]); | ||
|
||
// Retrieve an array of file objects from a bucket. | ||
$fileList = $client->listFiles([ | ||
'BucketId' => '4d2dbbe08e1e983c5e6f0d12' | ||
]); | ||
``` | ||
|
||
## Installation | ||
|
||
Installation is via Composer: | ||
|
||
```bash | ||
$ composer require gliterd/backblaze-b2 | ||
``` | ||
|
||
## Tests | ||
|
||
Tests are run with PHPUnit. After installing PHPUnit via Composer: | ||
|
||
```bash | ||
$ vendor/bin/phpunit | ||
``` | ||
|
||
## Contributors | ||
|
||
Feel free to contribute in any way you can whether that be reporting issues, making suggestions or sending PRs. :) | ||
|
||
## License | ||
|
||
MIT. |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "gliterd/backblaze-b2", | ||
"type": "library", | ||
"description": "PHP SDK for working with backblaze B2 cloud storage.", | ||
"keywords": ["cloud-storage", "b2", "storage", "backblaze", "cloud", "filesystem", "backup"], | ||
"homepage": "https://github.com/gliterd/b2-sdk-php", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Ramesh Mhetre", | ||
"email": "[email protected]", | ||
"homepage": "https://gliterd.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5.0", | ||
"guzzlehttp/guzzle": "^6.1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.8.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"BackblazeB2\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"BackblazeB2\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="b2-sdk-php tests"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace BackblazeB2; | ||
|
||
class Bucket | ||
{ | ||
const TYPE_PUBLIC = 'allPublic'; | ||
const TYPE_PRIVATE = 'allPrivate'; | ||
|
||
protected $id; | ||
protected $name; | ||
protected $type; | ||
|
||
/** | ||
* Bucket constructor. | ||
* | ||
* @param $id | ||
* @param $name | ||
* @param $type | ||
*/ | ||
public function __construct($id, $name, $type) | ||
{ | ||
$this->id = $id; | ||
$this->name = $name; | ||
$this->type = $type; | ||
} | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
} |
Oops, something went wrong.
3e68420
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original MIT license for this code is from cwhite92/b2-sdk-php