kamilz/b2backblaze-bundle

Symfony bundle for B2 Cloud Storage

v0.0.2 2017-06-17 13:11 UTC

This package is not auto-updated.

Last update: 2024-11-09 19:19:16 UTC


README

This bundle is a Symfony2 wrapper for b2backblaze library

About B2 Cloud Storage

B2 Cloud Storage is a cloud service for storing files in the cloud. Files are available for download at any time, either through the API or through a browser-compatible URL.

The documentation for B2 Cloud storage can be found at https://www.backblaze.com/b2/docs/.

Installation

The recommended way to install this bundle is through Composer.

Install Composer

curl -sS https://getcomposer.org/installer | php

Add B2BackblazeBundle as a dependency

php composer.phar require "kamilz/b2backblaze-bundle":"dev-master"

Enable the bundle in the kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new KamilZ\B2BackblazeBundle\B2BackblazeBundle(),
        // ...
    );
}

Add required configuration

##config.yml

b2_backblaze:
    account_id: YOUR_ID
    account_key: YOUR_ACCCOUNT_SECRET_KEY
    bucket_id: YOUR_BUCKET_ID
    bucket_region: 'https://fxxx.backblaze.com/file/YOUR_BUCKET_NAME/'
    timeout: 2000

Usage

Upload File:

<?php
    (...)
    $b2 = $this->get("backblaze.b2");

    $b2->uploadFile("...test.png","test.png");
    //or
    $b2->uploadFileByContent($file,"test.png");
    (...)

Twig image filter:

{# twig template #}
    (..)

    <img src="{{ app.user.avatar|b2 }}" alt="">

    (..)

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE