in server/pkg/cloud/storage/azure.go [49:95]
func (b *msAzureBlobBackend) GetObject(ctx context.Context, path string) (*Object, error) {
// Check arguments
if b.client == nil {
return nil, errors.New("azure: unable to obtain a client reference")
}
// Retrieve blob service
blobSrv := b.client.GetBlobService()
// Retrieve container
container := blobSrv.GetContainerReference(b.bucket)
if container == nil {
return nil, errors.New("azure: unable to obtain a container reference")
}
// Compute object path
objectPath := pathutil.Join(b.prefix, path)
// Check if object exists
blobReference := container.GetBlobReference(objectPath)
if blobReference == nil {
return nil, fmt.Errorf("azure: unable to retrieve blob reference for '%s'", objectPath)
}
// Check existence
exists, err := blobReference.Exists()
if err != nil {
return nil, fmt.Errorf("azure: unable to check blob existence for '%s': %w", objectPath, err)
}
if !exists {
return nil, fmt.Errorf("azure: object '%s' does not exist", objectPath)
}
readCloser, err := blobReference.Get(nil)
if err != nil {
return nil, fmt.Errorf("azure: unbale to open content reader for '%s': %w", objectPath, err)
}
// Assemble response
var object Object
object.Path = path
object.Content = readCloser
object.LastModified = time.Time(blobReference.Properties.LastModified)
// No error
return &object, nil
}