Upload and Download a Bitmap to Azure Container


  • Hi,  I'm using asp to write a small program that uploads a bitmap image to an azure container.  I have code to upload a text file and that works.  I cannot seem to get the right syntax to upload an image.  I have looked all over various forums and there are many variations.  None which work for me.  Here is my latest code.  No errors but no file is uploaded to the container either.

     Dim bounds As Rectangle = New Rectangle(25, 135, 600, 600)
            ' Dim tPath As String

            Using tBitmap As New Bitmap(bounds.Width, bounds.Height)

                Using g As Graphics = Graphics.FromImage(tBitmap)
                    g.CopyFromScreen(New Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size)
                End Using

                Dim memStream As New IO.MemoryStream
                tBitmap.Save(memStream, ImageFormat.Jpeg)

                Dim cloudStorageAccount__1 As CloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=XXX;AccountKey=XXX")
                Dim blobClient As CloudBlobClient = cloudStorageAccount__1.CreateCloudBlobClient()
                Dim blobContainer As CloudBlobContainer = blobClient.GetContainerReference("tempreportingpictures")
                ' If the container does not exist, we need to create it.
                ' Let us put public permissions on the container so we can access the file from anywhere.
                Dim containerPermissions As New BlobContainerPermissions()
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob
                Dim blob As CloudBlob = blobContainer.GetBlobReference("test.jpg")

                'Using fileStream = System.IO.File.OpenRead(cBitmap)
                'End Using

                ' File from local storage.
                MsgBox("File successfully uploaded")

    end using


    Wednesday, September 21, 2016 5:02 PM


All replies