{"record":{"id":"4625c5d42d7eada8","repo":"OrchardCMS/OrchardCore","slug":"error-creating-directory-path-ex-message","errorCode":null,"errorMessage":"Error creating directory '${path}': ${ex.Message}","messagePattern":"Error creating directory '(.+?)': (.+?)","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs","lineNumber":133,"sourceCode":"    public async Task<bool> TryCreateDirectoryAsync(string path)\n    {\n        try\n        {\n            var response = await _amazonS3Client.PutObjectAsync(new PutObjectRequest\n            {\n                BucketName = _options.BucketName,\n                Key = NormalizePrefix(this.Combine(_basePrefix, path)),\n            });\n\n            return response.IsSuccessful();\n        }\n        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)\n        {\n            return false;\n        }\n        catch (AmazonS3Exception ex)\n        {\n            throw new FileStoreException($\"Error creating directory '{path}': {ex.Message}\", ex);\n        }\n    }\n\n    public async Task<bool> TryDeleteFileAsync(string path)\n    {\n        try\n        {\n            var response = await _amazonS3Client.DeleteObjectAsync(new DeleteObjectRequest\n            {\n                BucketName = _options.BucketName,\n                Key = this.Combine(_basePrefix, path),\n            });\n\n            return response.IsDeleteSuccessful();\n        }\n        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)\n        {\n            return false;","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar ok = await fileStore.TryCreateDirectoryAsync(path); // silently assumes success\n// after\nvar ok = await fileStore.TryCreateDirectoryAsync(path);\nif (!ok) _logger.LogWarning(\"Could not create S3 directory {Path} — check permissions/credentials\", path);","handlingStrategy":"try-catch","validationCode":"// verify write access before directory creation:\nawait _s3.PutObjectAsync(new PutObjectRequest { BucketName = bucket, Key = probeKey, ContentBody = \"probe\" });","typeGuard":"bool IsAccessDenied(FileStoreException ex) => ex.InnerException is AmazonS3Exception s3 && s3.ErrorCode == \"AccessDenied\";","tryCatchPattern":"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); }","preventionTips":["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"],"tags":["aws","s3","file-storage","permissions","io"],"backgroundTag":"file-write-failed","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}