Advertisement
firedigger

Azure Blob Storage/S3

Apr 26th, 2024 (edited)
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. Upload to Blob storage
  2. ```
  3. BlobClient versionBlobClient = GetBlobContainerClient().GetBlobClient(itemVersionBlobName);
  4. versionBlobClient.Upload(itemBlobStream);
  5. ```
  6.  
  7. Upload to S3
  8. ```
  9. await transferUtility.UploadAsync(new TransferUtilityUploadRequest
  10. {
  11.     BucketName = bucketName,
  12.     Key = blobName,
  13.     InputStream = stream
  14. });
  15. ```
  16.  
  17. Download from Blob storage
  18. ```
  19. itemWrapper.DownloadInfo = new Core.DownloadInfo
  20. {
  21.     Content = await S3StorageLibrary.Utilities.GetContent(transferUtility, bucketName, itemContentBlobName, Key),
  22.     ContentLength = await S3StorageLibrary.Utilities.GetContentLength(S3Client, bucketName, itemContentBlobName, Key)
  23. };
  24. ```
  25.                        
  26. Download from S3                       
  27. ```
  28. string itemContentBlobName = Utilities.GetDriveItemContentBlobName(itemBlobName);
  29. Azure.Storage.Blobs.BlobClient itemBlobContentClient =
  30.     GetBlobContainerClient().GetBlobClient(itemContentBlobName);
  31. if (itemBlobContentClient.Exists())
  32. {
  33.     var contentBlobDownload = itemBlobContentClient.Download().Value;
  34.     itemWrapper.DownloadInfo = new Core.DownloadInfo
  35.     {
  36.         Content = contentBlobDownload.Content,
  37.         ContentLength = contentBlobDownload.ContentLength
  38.     };
  39. }
  40. ```
  41. Content is an object of type Stream
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement