summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryogg@epsina.com <evan.pisani@etudiant.univ-rennes1.fr>2016-01-31 18:28:09 +0100
committeryogg@epsina.com <evan.pisani@etudiant.univ-rennes1.fr>2016-01-31 18:28:09 +0100
commit6e7c71db77fc68b7c3d1149b830a838b81cdb718 (patch)
treec919846f1acf4d3d62dc5543d57399fc046910db
parent0db8d0ebbe36528346987cb21db67f31bfbe6017 (diff)
Add update_image and download_image
-rw-r--r--server/core/Image.php32
-rw-r--r--server/test.php13
2 files changed, 35 insertions, 10 deletions
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 "</br>";
//$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