-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.php
More file actions
70 lines (63 loc) · 2.66 KB
/
storage.php
File metadata and controls
70 lines (63 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
require_once 'vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Common\ServiceException;
$connectionString = "DefaultEndpointsProtocol=http;AccountName=iscloud;AccountKey=AxuXnblTRtFbRGD5p9tNnxeE5w6XMND+p66f/yWt/ugP8JG4bAKVRhCwPhljDM3rBuhQfyPAeujYTLtYpj9DFw==;";
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
if(isset($_GET['upload'])){
//uloží soubor jako stream
//
#$content = fopen("https://www.enterprise.com/content/enterprise_cros/data/vehicle/bookingCountries/US/TRUCKS/PPAR.doi.768.high.imageSmallThreeQuarterNodePath.png/1444355026452.png", "r");
//uloží klasicky
$content = file_get_contents("https://www.enterprise.com/content/enterprise_cros/data/vehicle/bookingCountries/US/TRUCKS/PPAR.doi.768.high.imageSmallThreeQuarterNodePath.png/1444355026452.png");
$blob_name = "pickup2.png";
try {
//Upload blob
$blobRestProxy->createBlockBlob("test", $blob_name, $content);
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
}
try {
#echo serialize($blobRestProxy->listContainers());
$containers = $blobRestProxy->listContainers();
$container = $containers->getContainers();
foreach ($container as $key) {
// List blobs.
$blob_list = $blobRestProxy->listBlobs($key->getName());
$blobs = $blob_list->getBlobs();
echo "Kontejner:" . $key->getName() . "<br/>";
foreach ($blobs as $blob) {
echo "Soubory:" . $blob->getName() . ": " . $blob->getUrl();
echo "<br />";
}
echo "_------------_<br/>";
}
} catch (ServiceException $e) {
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message . "<br />";
}
?>
<form action="" method="GET">
<input type="submit" name="upload" value="Upload" />
</form>
</body>
</html>