Search code examples
.netbackload

.net backload multiple filesroot


I am using Backload (https://github.com/blackcity/Backload) on the back end to store files, it has a few cool features but i was wondering if it is possible to have multiple filesRoot:

  1. Inside the application scope for content files, public.
  2. Outside the application scope for personal files, private.

OR

If there is a way to change the root directory on the fly using one of the Backloads server side events?


Solution

  • I ended up using a server side event: If there is a better way please let me know.

    private void handler_StoreFileRequestStarted(object sender,StoreFileRequestEventArgs e)
    {
       //Change paths
        var fullPath = _contentRoot + e.Param.FileStatusItem.ObjectContext + "\\" + e.Param.FileStatusItem.UploadContext + "\\photoid\\"; 
    
        e.Param.FileStatusItem.StorageInfo.FilePath = fullPath + "photoid.png";
    
        e.Param.FileStatusItem.StorageInfo.ThumbnailPath = fullPath + "_thumbs\\" + "photoid.png.png";
    
        e.Param.FileStatusItem.FileUrl = e.Param.FileStatusItem.FileUrl.Replace("files", content").Replace(e.Param.FileStatusItem.FileName, "photoid/photoid.png");
    
        e.Param.FileStatusItem.ThumbnailUrl = e.Param.FileStatusItem.ThumbnailUrl.Replace("files", "content").Replace("_thumbs/" + e.Param.FileStatusItem.ThumbnailName,"photoid/_thumbs/photoid.png.png");   
    
    }