Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Created June 9, 2015 03:55
Show Gist options
  • Select an option

  • Save dbousamra/bf903ca7e90feb5c03d3 to your computer and use it in GitHub Desktop.

Select an option

Save dbousamra/bf903ca7e90feb5c03d3 to your computer and use it in GitHub Desktop.
case class AzureStorage(storageAccount: CloudStorageAccount, blobClient: CloudBlobClient, implicit val ec: ExecutionContext) extends Storage {
def uploadFile(container: Container, data: Array[Byte], remoteFilename: RemoteFilename): AzureError \/ RemoteStorageUrl = {
for {
container <- getContainer(container)
uploadedBlob <- uploadBlob(container, data, remoteFilename)
url <- getURLFromBlob(uploadedBlob)
} yield RemoteStorageUrl(url)
}
private def getContainer(container: Container): Future[AzureError \/ CloudBlobContainer] = ???
private def uploadBlob(containerRef: CloudBlobContainer, data: Array[Byte], remoteFilename: RemoteFilename): Future[AzureError \/ CloudBlockBlob] =
private def getBlobReference(containerRef: CloudBlobContainer, remoteFilename: RemoteFilename): Future[AzureError \/ CloudBlockBlob] = ???
private def getURLFromBlob(blobRef: CloudBlockBlob): Future[AzureError \/ URL] = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment