Change default path for upload and cache storage

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Moderator: Alex

Post Reply
Johnsnow
Posts: 9
Joined: Wed Mar 02, 2022 3:07 pm

Change default path for upload and cache storage

Post by Johnsnow »

Hi,

I had created sample project by following this tutorial.
https://www.vintasoft.com/docs/vsimagin ... ation.html

Its working fine, but Its currently upload the files in the folder "wwwroot/UploadedImageFiles", and creating all cache data in the folder "wwwroot/VintasoftCache", I want to change these paths.

Please advise. And also can you advise to clear cache data programmatically after save/burn annotations.

Thanks,
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Change default path for upload and cache storage

Post by Alex »

Hi John,
Its working fine, but Its currently upload the files in the folder "wwwroot/UploadedImageFiles", and creating all cache data in the folder "wwwroot/VintasoftCache", I want to change these paths.
If you want to change name of upload directory from "UploadedImageFiles" to other name in ASP.NET Core project, you need to do the following steps:
  • Create custom API controller that is derived from VintaSoft API controller. For example, create MyVintasoftImageApiController class derived from Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftImageApiController class. Remember, you need to create custom API controller for each used web service, i.e. VintasoftImageApiController, VintasoftImageCollectionApiController, etc.
  • In created class override the CreateSessionDataStorage method. Here is example:

    Code: Select all

    protected override IDataStorage CreateSessionDataStorage(string sessionId)
    {
        if (sessionId == null)
        {
            if (IsEmptySessionSupported)
                sessionId = "";
            else
                throw new ArgumentNullException("sessionId");
        }
    
        string path = Path.Combine(HostingEnvironment.WebRootPath, "UploadedImageFiles", sessionId);
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);
    
        return new StreamDataStorageOnDisk(path);
    }
    

Please also read how to create custom data storage for image files here: https://www.vintasoft.com/docs/vsimagin ... abase.html


And also can you advise to clear cache data programmatically after save/burn annotations.
You can get image cache manager of web image viewer using the WebImageViewerJS.get_ImageCacheManager function.

The WebImageCacheManagerJS class allows to manage cache of web images.

Best regards, Alexander
Post Reply