'No olvides referenciar Microsoft.WindowsAzure.StorageClient
Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.StorageClient
Private Function enviarBLOB() As Boolean
Dim Path As String = "C:\Temp\prova.pdf"
Dim FS As FileStream = File.OpenRead(Path)
Dim StorageAccount As CloudStorageAccount
Dim BlobClient As CloudBlobClient
Dim BlobContainer As CloudBlobContainer
Dim sendOK As Boolean = False
Try
StorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=" & AccountName & ";AccountKey=" & AccountKey)
BlobClient = StorageAccount.CreateCloudBlobClient
BlobClient.Timeout = New System.TimeSpan(1, 0, 0)
BlobClient.ParallelOperationThreadCount = 2
BlobContainer = BlobClient.GetContainerReference(ContainerName)
Dim myGUID As System.Guid = System.Guid.NewGuid()
Dim sGUID As String = myGUID.ToString()
Dim Blob As CloudBlob = BlobContainer.GetBlobReference(sGUID)
Blob.UploadFromStream(FS)
Blob.Metadata("no") = "12134"
Blob.Metadata("Nombre") = "Pepe"
Blob.Metadata("timestamp") = Now
Blob.SetMetadata()
Blob.Properties.ContentType = "application/pdf"
Blob.Properties.ContentEncoding = "base64"
Blob.SetProperties()
sendOK = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Return sendOK
End Function
Private Function urlBLOB_paraDescarga(ContainerName As String, Filename As String, AccountName As String, AccountKey As String, accessMinutesExpiry As Integer) As String
Dim StorageAccount As CloudStorageAccount
Dim BlobClient As CloudBlobClient
Dim BlobContainer As CloudBlobContainer
Dim Options As New BlobRequestOptions
StorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=" & AccountName & ";AccountKey=" & AccountKey)
BlobClient = StorageAccount.CreateCloudBlobClient
BlobClient.Timeout = New System.TimeSpan(1, 0, 0)
BlobClient.ParallelOperationThreadCount = 2
BlobContainer = BlobClient.GetContainerReference(ContainerName)
Dim Blob As CloudBlob = BlobContainer.GetBlobReference(Filename)
Dim SHaccesPolicy As New SharedAccessPolicy()
SHaccesPolicy.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(accessMinutesExpiry)
SHaccesPolicy.Permissions = SharedAccessPermissions.Read
Dim signature As String = Blob.GetSharedAccessSignature(SHaccesPolicy)
Return Blob.Uri.AbsoluteUri + signature
End Function
No hay comentarios:
Publicar un comentario