- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExternalFileSystemStorageProvider.cs
More file actions
Latest commit
63 lines (48 loc) · 2.41 KB
/
Copy pathExternalFileSystemStorageProvider.cs
File metadata and controls
63 lines (48 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
usingSystem;
usingSystem.IO;
usingTelerik.Sitefinity.BlobStorage;
usingTelerik.Sitefinity.Modules.Libraries.BlobStorage;
namespaceSitefinityWebApp.Helpers{
publicclassExternalFileSystemStorageProvider:FileSystemStorageProvider,IExternalBlobStorageProvider{
protectedoverridevoidInitializeStorage(System.Collections.Specialized.NameValueCollectionconfig){
base.InitializeStorage(config);
varurl=string.Concat(Telerik.Sitefinity.Services.SystemManager.RootUrl,config["rootUrl"]);
this.rootUrl=url;
if(this.rootUrl.IsNullOrEmpty()){
this.rootUrl=Telerik.Sitefinity.Services.SystemManager.RootUrl;
if(this.StorageFolder.StartsWith(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath,StringComparison.OrdinalIgnoreCase)){
varpathFromRoot=this.StorageFolder.Substring(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath.Length);
pathFromRoot.Replace('\\','/');
this.rootUrl+=pathFromRoot;
}
}
}
publicvoidCopy(IBlobContentLocationsource,IBlobContentLocationdestination){
File.Copy(this.GetFilePath(source),this.GetFilePath(destination));
}
publicstringGetItemUrl(IBlobContentLocationcontent){
returnstring.Concat(this.rootUrl,"/",content.FilePath);
}
publicIBlobPropertiesGetProperties(IBlobContentLocationlocation){
returnnull;
}
publicvoidMove(IBlobContentLocationsource,IBlobContentLocationdestination){
File.Move(this.GetFilePath(source),this.GetFilePath(destination));
}
publicvoidSetProperties(IBlobContentLocationlocation,IBlobPropertiesproperties){
}
publicoverrideStreamGetUploadStream(IBlobContentcontent){
EnsureFilePath(content);
returnbase.GetUploadStream(content);
}
protectedoverridestringGetFilePath(IBlobContentLocationlocation){
returnPath.Combine(this.StorageFolder,location.FilePath);
}
privatevoidEnsureFilePath(IBlobContentLocationlocation){
FileInfofile=newFileInfo(this.GetFilePath(location));
if(!file.Directory.Exists)
file.Directory.Create();
}
privatestringrootUrl;
}
}