OrchardCMS/OrchardCore · error · FileStoreException
Error creating directory
Error message
Error creating directory '${path}': ${ex.Message} What it means
AwsFileStorage.TryCreateDirectoryAsync attempts to create the S3 prefix placeholder and wraps any unexpected AmazonS3Exception in FileStoreException. NotFound is treated as 'directory not created' (false); every other S3 failure (credentials, permissions, throttling) raises this error with the path and S3 message.
Solutions
- Grant s3:PutObject (and s3:ListBucket) on the bucket/prefix to the configured credentials
- Verify bucket name/region/credentials in the Amazon S3 media settings
- Inspect the inner exception ErrorCode for the precise AWS failure
- Retry transient throttling errors with backoff
Example fix
// before
var ok = await fileStore.TryCreateDirectoryAsync(path); // silently assumes success
// after
var ok = await fileStore.TryCreateDirectoryAsync(path);
if (!ok) _logger.LogWarning("Could not create S3 directory {Path} — check permissions/credentials", path); Defensive patterns
Strategy: try-catch
Validate before calling
// verify write access before directory creation:
await _s3.PutObjectAsync(new PutObjectRequest { BucketName = bucket, Key = probeKey, ContentBody = "probe" }); Type guard
bool IsAccessDenied(FileStoreException ex) => ex.InnerException is AmazonS3Exception s3 && s3.ErrorCode == "AccessDenied";
Try / catch
try { ok = await fileStore.TryCreateDirectoryAsync(path); } catch (FileStoreException ex) { _logger.LogError(ex.InnerException, "S3 mkdir failed for {Path}: {Code}", path, (ex.InnerException as AmazonS3Exception)?.ErrorCode); } Prevention
- Ensure IAM credentials allow s3:PutObject on the folder prefix
- Confirm bucket name/region in Amazon S3 media settings
- Use exponential backoff retries for throttled bulk imports
- Fail startup fast if a connectivity/write probe fails
When it happens
Trigger: Calling TryCreateDirectoryAsync(path) when the PutObject (or listing) call for the directory marker fails with a non-404 AmazonS3Exception — e.g. AccessDenied on the prefix or invalid bucket configuration.
Common situations: Read-only IAM credentials used for a write-capable store; missing s3:PutObject permission for the folder prefix; S3 throttling during bulk imports; misconfigured bucket in tenant settings.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Error deleting file
- Error retrieving file info for
- Cannot delete root directory.
- Error accessing file
- Error while copying file
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/4625c5d42d7eada8.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs:133
public async Task<bool> TryCreateDirectoryAsync(string path)
{
try
{
var response = await _amazonS3Client.PutObjectAsync(new PutObjectRequest
{
BucketName = _options.BucketName,
Key = NormalizePrefix(this.Combine(_basePrefix, path)),
});
return response.IsSuccessful();
}
catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
return false;
}
catch (AmazonS3Exception ex)
{
throw new FileStoreException($"Error creating directory '{path}': {ex.Message}", ex);
}
}
public async Task<bool> TryDeleteFileAsync(string path)
{
try
{
var response = await _amazonS3Client.DeleteObjectAsync(new DeleteObjectRequest
{
BucketName = _options.BucketName,
Key = this.Combine(_basePrefix, path),
});
return response.IsDeleteSuccessful();
}
catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
return false;View on GitHub (pinned to 4306c0717f)