Page 1 of 1
Change default path for upload and cache storage
Posted: Thu Mar 03, 2022 10:20 am
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,
Re: Change default path for upload and cache storage
Posted: Thu Mar 03, 2022 8:18 pm
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