Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Local filesystem
  2. Amazon Simple Storage System (S3)
  3. Digital Ocean Space
  4. FTP storage file system via FTP connect
  5. SFTP server via SSH connect
  6. S3 Compatible storage system (see https://help.servmask.com/knowledgebase/list-of-s3-compatible-storage-providers/List of S3-compatible storage providers )

Below are some sample codes to manipulate files with storage systems on phpFox site:

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsetrue
<?php

// Get storage object associate with storageId = 1.
$storage = Phpfox::getLib('storage')->getStorage(1);

// Get default storage
$storage = Phpfox::getLib('storage')->getStorage();

// Get default storage Id
$defaultStorageId = Phpfox::getLib('storage')->getStorageId();

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsefalse
<?php
//get default Storage system
$storage = Phpfox::getLib('storage')->getStorage(); 
$path =  'PF.Base/file/new-file-api.txt';

// @param string $path     The path to the file.
// @param string $contents The file contents.
// @param array  $config   An optional configuration array.
// @return string full url of file

$fileUrl = $storage->getUrl($path);

?>

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsefalse
<?php

$path =  'PF.Base/file/new-file-api.txt';
$content = 'file api content';
$config = ['visibility'=>'public'];
$storage = Phpfox::getLib('storage')->getStorage();

// @param string $path     The path to the file.
// @param string $contents The file contents.
// @param array  $config   An optional configuration array.
// @return bool True on success, false on failure.

$isSuccessful = $storage->put($path, $contents, $config);

?>

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsefalse
<?php

$storage = Phpfox::getLib('storage')->getStorage();
$path =  'PF.Base/file/new-file-api.txt';

// Retrieves a read-stream for a path.
// @param string $path The path to the file.
// @throws FileNotFoundException
// @return resource|false The path resource or false on failure.
$stream$fileStream = $storage->readStream($path);
?>

...