IFileStoreService SQL Implmentation (Questions and Working Example)
See original GitHub issueHey Joel,
I’m on a roll over here, back again with a question that’s stumping me a bit regarding an implementation of IFileStoreService i’ve written, i’ll share the code in a secondary comment as to not clutter the main issue text up. Just as a precursor, i’ve created an SqlBinaryFilestoreService
to store assets inside sql server as byte arrays, since there won’t be a ton of images or documents uploaded, it felt necessary to just store them in the DB and not worry about them being accidentally removed at any point due to a deployment or the likes.
The issue i’m seeing is that DeleteAsync
, DeleteDirectoryAsync
, ClearDirectoryAsync
, ClearContainerAsync
are never hit. When i create the image in the admin panel, it uses my Create methods just fine and transposes the stream into a byte array, and getting the image works the same way, the methods get hit. But when i delete an image or asset, it never hits these deletion methods. I should note, i’m using the ImageSharp image asset plugin you provided to handle that side of things.
I even stopped my IFileStoreService implementation from injecting and overriding itself and reverted back to using the built in FileSystemFileStorageService (again using the ImageSharp plugin as well). And to my suprise, not even those files get deleted from the file system when you delete them in the CMS.
Any thoughts? I’d be happy to provide this as an example for those who want to do something similar when it’s all cleaned up and working correctly in the deletion aspect of things)
I’ll post the code below.
Thanks again for all the help and insight!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
EDIT: @HeyJoel Updated with complete FileStoreService for SQL solution, i’m sure it can be cleaned up or optimized a tiny bit, but i’m confident that it works and does what I need it to do.
IFileStoreService Implentation
Custom DB Context and Entity Initialization
Cofoundry DI For Custom DBContext
Thanks for the note about the HangFire upgrade, I had seen that there’s a tricky migration to do for 1.7 but had not seen anything about the cron expressions, I’ve now added an issue for it on that repo.
I’ll leave this open as a reminder to update the docs for the
AssetFileCleanupSettings
.