Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended services to handle folders as files. #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cumulus.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Cumulus implements CumulusInterface {
protected $config = array();
public static $CHEMIN_CONFIG = "config/config.json";


/** Implémentation de la lib de stockage par un adapteur */
protected $storageAdapter;

Expand Down Expand Up @@ -64,6 +65,12 @@ public function setAuthAdapter($adapter) {
$this->storageAdapter->setAuthAdapter($adapter);
}


public function createNewFolder($folderName, $path) {
return $this->storageAdapter->createNewFolder($folderName, $path);
}


/**
* Retourne le chemin racine du stockage de fichiers
*/
Expand Down Expand Up @@ -242,4 +249,4 @@ public function deleteByKey($key, $keepFile=false) {
public function getAttributesByKey($key) {
return $this->storageAdapter->getAttributesByKey($key);
}
}
}
8 changes: 5 additions & 3 deletions CumulusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ protected function explode($delimiter, $string) {
* n'est spécifié, modifie les métadonnées de la clef ciblée
*/
protected function post() {

$nameOrKey = array_pop($this->resources);
$path = '/' . implode('/', $this->resources);

Expand All @@ -768,6 +769,7 @@ protected function post() {
if (! empty($_SERVER["CONTENT_TYPE"])) {
$serverContentType = $_SERVER["CONTENT_TYPE"];
}

// détection de la méthode d'envoi
$isMPFD = strtolower(substr($serverContentType, 0, 19)) == 'multipart/form-data';
if ($isMPFD) { // envoi de formulaire classique avec multipart/form-data
Expand Down Expand Up @@ -822,8 +824,9 @@ protected function post() {

$info = false;
if ($file == null) {
// mise à jour métadonnées seulement
$info = $this->lib->updateByKey($key, $newname, $newpath, $keywords, $groups, $permissions, $license, $meta);

// création d'un répertoire
$info = $this->lib->createNewFolder($nameOrKey, $path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le commentaire ne correspond plus

} else {
// ajout / mise à jour de fichier
$info = $this->lib->addOrUpdateFile($file, $path, $nameOrKey, $keywords, $groups, $permissions, $license, $meta);
Expand Down Expand Up @@ -855,4 +858,3 @@ protected function delete() {


}