Comments (1)
it is created because the Blob storage provider you are using is not one that supports IHierarchicalBlobStorage
so the only way to create a folder, is to put an empty file in it, otherwise the folder won't exist.
You can name it something different as the method signature support providing a different name but I've found that in cases where the storage provider doesn't actually support IHierarchicalBlobStorage
, that they support full path and folder creation when creating files and actually don't need to have folders created prior to writing of files. if your implementation is only targetting one of these, then you can either explicitly ignore the files, or refactor to not use the CreateFolderAsync extension method
/// <summary>
/// Creates a new folder in this storage. If storage supports hierarchy, the folder is created as is, otherwise a folder is created by putting a dummy zero size file in that folder.
/// </summary>
/// <param name="blobStorage"></param>
/// <param name="folderPath">Path to the folder</param>
/// <param name="dummyFileName">If storage doesn't support hierary, you can override the dummy file name created in that empty folder.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task CreateFolderAsync(
this IBlobStorage blobStorage, string folderPath, string dummyFileName = null, CancellationToken cancellationToken = default) {
if (blobStorage is IHierarchicalBlobStorage hierarchicalBlobStorage) {
await hierarchicalBlobStorage.CreateFolderAsync(folderPath, cancellationToken).ConfigureAwait(false);
}
else {
string fullPath = StoragePath.Combine(folderPath, dummyFileName ?? ".empty");
// Check if the file already exists before we try to create it to prevent
// AccessDenied exceptions if two processes are creating the folder at the same time.
if (await blobStorage.ExistsAsync(fullPath)) {
return;
}
await blobStorage.WriteTextAsync(
fullPath,
"created as a workaround by FluentStorage when creating an empty parent folder",
null,
cancellationToken).ConfigureAwait(false);
}
}
from fluentstorage.
Related Issues (20)
- Encryption for stored blobs fails to decrypt HOT 4
- Confusing different behaviour between Azure, Memory, Disk & Zip modules. HOT 4
- ZipArchive backed IBlobStorage throws occasionally when calling WriteAsync HOT 2
- ZipArchive contains empty named folder at root HOT 2
- DiskDirectoryBlobStorage saves Metadata Attribute files unencrypted if encryption is set in the pipeline HOT 1
- Azure Datalake Blob storage gen2 regression HOT 1
- Connection strings containing special URL encoding characters are mangled HOT 2
- Azure Servicebus: Migrate to new SDK and imeplement missing methods HOT 2
- Setting Content-Type of an Azure blob HOT 1
- Aws s3 incorrect handle content-type: application/xml; charset=utf-8 HOT 2
- support .NET 8 HOT 3
- [Bug] WriteFileAsync will not reduce file size resuling in data leak (SFTP) HOT 2
- [Bug] ListAsync recursion does not work for FTP HOT 1
- [Bug] ListAsync recursion does not work for SFTP HOT 1
- [Bug] FluentStorage.SFTP WriteAsync with append=true does not do anything HOT 1
- [Request] Remove dependency of Renci.SshNet.Async HOT 5
- GCP Storage provider DeleteAsync will delete all files in bucket if target full path object is not found HOT 2
- FluentStorage.Azure.Blobs - vulnerable package dependencies
- The MinIO extension method in FluentStorage.Factory is missing the "IBlobStorageFactory this" parameter HOT 4
- Creation of Azure storage from connection string failed for shared key credentials
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentstorage.