PHP Classes

File: examples/03-deleting-file.php

Recommend this page to a friend!
  Classes of Alexandre Sinício   PHP Cloud Storage Abstraction   examples/03-deleting-file.php   Download  
File: examples/03-deleting-file.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Cloud Storage Abstraction
Store and retrieve data in multiple cloud services
Author: By
Last change:
Date: 6 years ago
Size: 769 bytes
 

Contents

Class file image Download
<?php
use SinFramework\Storage\LocalStorage;

require
'../bootstrap.php';
require
'../vendor/autoload.php';

//OUR GLOBAL VARS FOR THIS EXAMPLE
$fileID = '1234567890_1234567890';
$bucket = 'mybucket';

//GET STORAGE OBJECT
$storage = getStorageObj();

//DELETE FILE
try {
   
$storage->deleteFile($fileID, $bucket);
} catch (
Exception $e) {
    die(
$e->getMessage());
}

//THIS FUNCTION IS RESPONSIBLE FOR CREATING AND SETTING UP THE STORAGE OBJECT
//IN A REAL WORLD APPLICATION, IT SHOULD BE CONTAINED IN SOME KIND OF DEPENDENCY INJECTOR CONTAINER
/**
 * @return \SinFramework\Storage\StorageInterface
 */
function getStorageObj() {
   
$storageObj = new LocalStorage();
   
$storageObj::setBaseStorageLocation('../storage');
   
    return
$storageObj;
}