diff --git a/server/core/Image.php b/server/core/Image.php index c9d9845..a986a40 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -67,18 +67,24 @@ class Image { return $image; } - + /** + * Details about an image + * + * @param string $id + * id of the image + * + * @param array $opt + * options for the image creation + **/ public function update_image($id, array $opt){ $service = $this->oidentity; - - //OPTIONS A VOIR $image = $service->getImage($id); $image->update([ - 'minDisk' => 1, - 'minRam' => 1, - 'name' => $opt[name], - 'protected' => false, - 'visibility' => $opt[visibility], + 'minDisk' => $opt['minDisk'], + 'minRam' => $opt['minRam'], + 'name' => $opt['name'], + 'protected' => $opt['protected'], + 'visibility' => $opt['visibility'], ]); return $image; @@ -135,11 +141,17 @@ class Image { $image->uploadData($stream); } - // RETOUR A VOIR - public function download_image($id){ + /** + * Download an image + * + * @param string $id + * identifier of the image + */ + public function download_image($id){ $service = $this->oidentity; $image = $service->getImage($id); $stream = $image->downloadData(); + return $stream; } } ?> diff --git a/server/test.php b/server/test.php index 322dee4..71039e8 100644 --- a/server/test.php +++ b/server/test.php @@ -76,4 +76,17 @@ echo "
"; //$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso"; //$image->upload_image($id_image, $file_name); +//$image->download_image($id_image); + +/* +$opt_update = Array(); +$opt_update['name'] = "TestUpdate"; +$opt_update['visibility'] = 'public'; +$opt_update['minDisk'] = 1; +$opt_update['protected'] = false; +$opt_update['minRam'] = 15; + +$update = $image->update_image($id_image, $opt_update); +echo $update->name; +*/ ?> \ No newline at end of file