Permalink
Browse files

added support for downloading blobs

  • Loading branch information...
1 parent 99be829 commit de9e0134cfffb281154ed52ae1df369ceef2d39a @richorama committed Nov 10, 2013
Showing with 17 additions and 15 deletions.
  1. +3 −12 index.html
  2. +14 −3 server.js
View
@@ -17,16 +17,7 @@
<style>
- h2 {
- font-weight: normal;
- color:gray;
- text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
- }
- h3 {
- font-weight: normal;
- color:gray;
- text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
- }
+
.vertOffset
{
margin-top: 13px;
@@ -182,7 +173,7 @@ <h4 class="modal-title">Enter Your Windows Azure Storage Account and Key</h4>
<div class="col-md-2" id="containerList">
</div>
- <div class="col-md-2">
+ <div class="col-md-10">
<div id="blobList">
</div>
@@ -218,7 +209,7 @@ <h4 class="modal-title">Enter Your Windows Azure Storage Account and Key</h4>
</tr>
{{#each blobs}}
<tr>
- <td><a href="{{url}}">{{name}}</a></td>
+ <td><a href="{{xurl}}">{{name}}</a></td>
<td>{{properties.BlobType}}</td>
<td>{{properties.Content-Length}}</td>
<td>{{properties.Content-Type}}</td>
View
@@ -52,9 +52,20 @@ app.get('/containers', function(req, res){
});
});
-app.get('/containers/:blob', function(req, res){
+function getDate(){
+ var date = new Date();
+ date.setHours((date).getHours() + 1);
+ return date;
+}
+
+app.get('/containers/:container', function(req, res){
var blobService = azure.createBlobService(req.headers.account, req.headers.key);
- blobService.listBlobs(req.params.blob, function(error, blobs, nextMarker, response){
+ blobService.listBlobs(req.params.container, function(error, blobs, nextMarker, response){
+
+ blobs.forEach(function(blob){
+ blob.xurl = blobService.generateSharedAccessSignature(req.params.container, blob.name, { AccessPolicy : { Permissions : "r", Expiry : getDate() } }).url();
+ });
+
if (error){
console.error(error);
}
@@ -161,4 +172,4 @@ app.post('/containers/:container',function(req, res){
});
app.listen(process.env.port || 210);
-console.log("listening on port " + (process.env.port || 210));
+console.log("listening on port " + (process.env.port || 210));

0 comments on commit de9e013

Please sign in to comment.