alexander-mitov/mongo-filesystem

在MongoDB之上实现文件系统

v1.0.4 2014-05-19 12:51 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:07:35 UTC


README

使用MongoDB作为存储引擎的分层文件系统在PHP中的实现。该库使用MongoDB GridFS编程接口来存储文件,并使用标准集合来存储文件夹信息。MongoFilesystem中有文件夹和文件的面向对象表示,以及丰富的API来对这些文件和文件夹进行操作。同时也有用于JSON/HTML/XML的文件/文件夹渲染器。

要求

  • PHP >= 5.4.0
  • MongoDB PHP驱动 >= 1.4.0
  • PHP SimpleXML扩展
  • 为了使用文件夹压缩功能,您需要PHP Zip扩展 >= 1.1.0

安装

  1. 安装Composer https://getcomposer.org.cn/doc/00-intro.md
  2. 添加到您的composer.json
        "alexander-mitov/mongo-filesystem": "1.0.*"
    }```
    
  3. 运行composer install命令。

基本使用

查看示例项目: https://github.com/AlexanderMitov/Demo_Project_Of_MongoFilesystem

提示

从MongoFilesystem(或使用\MongoFilesystem\File从本地fs)获取文件夹意味着递归/迭代地遍历其所有子文件夹和子文件夹的子文件夹等。当对文件夹或其子文件夹执行上传/更新/删除操作时,这是一个非常方便的功能,但如果不只是需要文件夹的名称或其他属性,则可能不是最佳选择。在这种情况下,将\MongoFilesytem::getFolder()的第二个参数设置为false以避免遍历子文件夹。这也意味着您不应该对没有设置子文件夹的文件夹执行上传/更新/删除操作,这是显而易见的。

API

  • MongoFilesystem::__construct(MongoDB)
  • MongoFilesystem::createFolder(string, string)
  • MongoFilesystem::deleteFile(MongoFile)
  • MongoFilesystem::deleteFolder(MongoFolder)
  • MongoFilesystem::downloadAndOutputFile(MongoFile)
  • MongoFilesystem::downloadAndOutputFolder(MongoFolder, boolean)
  • MongoFilesystem::downloadFile(MongoFile)
  • MongoFilesystem::downloadFileInFile(MongoFile)
  • MongoFilesystem::downloadFileInFolder(MongoFile, string)
  • MongoFilesystem::downloadFolderInFile(MongoFolder, string)
  • MongoFilesystem::downloadFolderInFolder(MongoFolder, string)
  • MongoFilesystem::fileWithIDExists(MongoId)
  • MongoFilesystem::fileWithNameExistsInFolder(string, string, MongoId)
  • MongoFilesystem::fileWithPathExists(string, string)
  • MongoFilesystem::filesAreIdentical(MongoId, File)
  • MongoFilesystem::folderWithIDExists(MongoId)
  • MongoFilesystem::folderWithNameAndParentFolderIDExists(string, MongoId)
  • MongoFilesystem::folderWithNameExistsInFolder(string, MongoId)
  • MongoFilesystem::folderWithPathExists(string, string)
  • MongoFilesystem::getFile(MongoId)
  • MongoFilesystem::getFileByNameAndParentFolderID(string, string, MongoId)
  • MongoFilesystem::getFileByPath(string, string)
  • MongoFilesystem::getFileIDByNameAndParentFolderID(string, string, MongoId)
  • MongoFilesystem::getFileIDByPath(string, string)
  • MongoFilesystem::getFilePath(MongoFile, boolean, string)
  • MongoFilesystem::getFileResourceStream(MongoId)
  • MongoFilesystem::getFolder(MongoId, boolean)
  • MongoFilesystem::getFolderByNameAndParentFolderID(string, MongoId)
  • MongoFilesystem::getFolderByPath(string, string)
  • MongoFilesystem::getFolderByPath(string, string)
  • MongoFilesystem::getFolderFiles(MongoId)
  • MongoFilesystem::getFolderIDByNameAndParentFolderID(string, MongoId)
  • MongoFilesystem::getFolderIDByPath(string, string)
  • MongoFilesystem::getFolderParentFolderID(MongoId)
  • MongoFilesystem::getFolderPath(MongoId, boolean, string)
  • MongoFilesystem::getFolderSubfolders(MongoId)
  • MongoFilesystem::getParentFolder(mixed)
  • MongoFilesystem::moveFileInFolder(MongoId, MongoId)
  • MongoFilesystem::moveFolderInFolder(MongoId, MongoId)
  • MongoFilesystem::renameFile(MongoId, string, string)
  • MongoFilesystem::renameFolder(MongoId, stirng)
  • MongoFilesystem::updateFile(MongoId, File)
  • MongoFilesystem::updateFolder(MongoId, Folder)
  • MongoFilesystem::uploadFile(File, MongoId, boolean)
  • 上传文件夹:MongoFilesystem::uploadFolder(Folder, MongoId)
  • 递归上传文件夹:MongoFilesystem::uploadRecursivelyFolder(Folder, MongoId)