Programmatically get the BasePath defined for PublicDiskBlobStorageProvider

Vote:
 

Hi,

I'm using EPiServer Commerce 1 and I need to get access to the basePath attribute defined in baf.config for the default storage provider PublicDiskBlobStorageProvider. Is there a way to get to this using the EPiServer API, or do I need to parse the baf.config file "manually" and find the wanted element?

<storageProvider defaultProvider="PublicDiskBlobStorageProvider">
<providers>
<add name="PublicDiskBlobStorageProvider" type=" Mediachase.BusinessFoundation.Blob.PublicDiskStorageProvider, Mediachase.BusinessFoundation" allowSearch="False" basePath="\\avenlndvrt058\Shared\BlobStorage" />

</providers>

Any tips?

Brgds

Jonas

#86607
May 26, 2014 15:54
Vote:
 

Correction, I'm using EPiServer Commerce 1.1. 

Brgds

Jonas

#86608
May 26, 2014 15:57
Vote:
 

I've found the solution. To get information about the current provider for BlobStorage, use BlobStorage.Provider and then cast it into PublicDiskStorageProvider to access the basePath property.

var blobStorage = (PublicDiskStorageProvider)BlobStorage.Provider;
var file = new FileStream(blobStorage.BasePath + header.BlobUid.ToString("N") + @"\" + header.Name, FileMode.Open, FileAccess.Read);

Brgds

Jonas

#86644
May 27, 2014 12:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.