Repository navigation
FileSystem BlueprintFileSystem
BlueprintFileSystem, in the Blueprint.FileSystem namespace, is the abstract base class for synchronous file and directory operations. A CMS can write a product photo through this API and a website can resolve its public URL using the same relative path.
| Provider | Storage |
|---|---|
| LocalFileSystem | A directory on the machine running the application. |
| FtpFileSystem | A directory on an FTP server, with an optional explicit TLS connection. |
Pass paths relative to the configured storage root, such as Products/Photos/1.png. Use forward slashes between names and omit leading or trailing slashes, empty segments, . and ... For batch operations, supply the directory once and pass individual file names such as 1.png and 2.png.
Both constructors require a publicBaseURL. Supply the absolute HTTP or HTTPS directory URL where the web server serves the storage root. Credentials, query strings and fragments are invalid. A trailing slash is optional.
GetPublicUrl(path) takes the unescaped relative path, URL-encodes each name, and returns a Uri without accessing storage. For example, a base URL of http://localhost:5051/assets/ and a path of Products/Photos/Front view.png produce http://localhost:5051/assets/Products/Photos/Front%20view.png. Configure the web server to serve that directory.
| Method | What it does |
|---|---|
FileExists(path), DirectoryExists(path)
|
Check for a file or directory, respectively. |
GetFiles(path), GetDirectories(path)
|
Return a List<string> of immediate file or subdirectory names. An existing directory with no matching entries yields an empty list. |
CreateDirectory(path) |
Request creation of the directory directly. See each provider's handling of existing and parent directories. |
DeleteDirectory(path, recursiveDelete = false) |
Delete an empty directory. Pass true to delete its contents and subdirectories as well. |
ReadFile(path), ReadFiles(path, fileNames)
|
Open one readable Stream or return a List<Stream> in file-name order. The caller disposes every returned stream. |
WriteFile(path, content), WriteFiles(path, streams, finalNames)
|
Write directly to the final names in an existing directory, replacing existing contents. Each source is read from its current position and remains owned by the caller. |
MoveFile(sourcePath, destinationPath) |
Move or rename a file within the provider. Include the final file name in the destination path. The destination directory must exist. |
DeleteFile(path), DeleteFiles(path, fileNames)
|
Request deletion directly, in list order for a batch. |
GetPublicUrl(path) |
Return the absolute public URL for a relative file path. |
WriteFiles requires one final name per stream and pairs entries by index. If a write or delete fails partway through a batch, completed operations remain in effect. An interrupted write can leave a partial file at its final name. When storing a new photo, publish its database reference after the write succeeds.
LocalFileSystem · FtpFileSystem · Class source · User manual