FoundatioFx / Foundatio

Pluggable foundation blocks for building distributed apps.
Apache License 2.0
1.99k stars 244 forks source link

How to delete pattern #233

Closed johnnygiter closed 4 years ago

johnnygiter commented 4 years ago

Hi, I want delete certain path bucket in aws s3 using regexp for example bucketname://client1/test/2020-01-02/files/objectstodelete bucketname://client2/test/2020-01-02/files/objectstodelete

So it should delete by date "2020-01-02" two paths for both client1 and client2 in the same bucket leaving all other untouched Is that possible using your code? How to?

niemyjski commented 4 years ago

Hello,

You'd need to call DeleteFilesAsync with a pattern: https://github.com/FoundatioFx/Foundatio/blob/master/src/Foundatio/Storage/IFileStorage.cs#L21 You'd pass it a string regex (https://github.com/FoundatioFx/Foundatio.AWS/blob/master/src/Foundatio.AWS/Storage/S3FileStorage.cs#L186-L226). I think you'd do */test/2020-01-02/files/objectstodelete Have you tried this?

johnnygiter commented 4 years ago

Thanks but need full sample.

niemyjski commented 4 years ago

Hello,

Please try calling that method: here is a unit test https://github.com/FoundatioFx/Foundatio/blob/7389bc5e15b158de89f8afc672be95ee0cdef1e0/src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs#L269