aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Transport/Web/StorageBlobStream.cs
blob: f4cbf7f62d9f45f6613e4bfa3f5992501313b09a (plain)
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
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.Transport.Web
{
    public class StorageBlobStream : IDisposable
    {
        public CloudBlockBlob Blob { get; private set; }
        private Stream _blobStream;

        public String Address { get; private set; }

        private StorageBlobStream(CloudBlockBlob blob)
        {
            Blob = blob;
        }

        public StorageBlobStream(String blobAddress) : this(new CloudBlockBlob(new Uri(blobAddress)))
        {
            Address = blobAddress;
        }

        public Stream OpenRead()
        {
            _blobStream = Blob.OpenRead();
            return _blobStream;
        }

        public Stream OpenWrite()
        {
            _blobStream = Blob.OpenWrite();
            return _blobStream;
        }

        public void Dispose()
        {
            _blobStream?.Dispose();
        }
    }
}