OrchardCMS/OrchardCore · error · FileStoreException

Error accessing file

Error message

Error accessing file '${srcPath}': ${ex.Message}

What it means

Any AmazonS3Exception raised by GetObjectMetadataAsync during CopyFileAsync that is not a 404 is wrapped in a FileStoreException carrying the S3 error message. This reports general S3 access failures (auth, permissions, network, throttling) while checking the source file.

Solutions

  1. Read the inner exception message to identify the S3 error code and fix credentials/permissions accordingly.
  2. Verify AWS credentials and IAM policy allow s3:GetObject (and HeadObject) on the bucket/prefix.
  3. Ensure the configured region/service URL matches the bucket's region.
  4. Retry with backoff if the error is throttling (SlowDown) or a transient 5xx.

Example fix

// before
await fileStore.CopyFileAsync(srcPath, dstPath);

// after
try
{
    await fileStore.CopyFileAsync(srcPath, dstPath);
}
catch (FileStoreException ex)
{
    _logger.LogError(ex, "S3 copy of '{Src}' failed", srcPath);
    throw;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify configuration before use
if (string.IsNullOrEmpty(_awsOptions.BucketName) || string.IsNullOrEmpty(_awsOptions.AccessKey))
{
    throw new InvalidOperationException("AWS S3 storage is not configured.");
}

Try / catch

try
{
    await fileStore.CopyFileAsync(srcPath, dstPath);
}
catch (FileStoreException ex)
{
    _logger.LogError(ex, "S3 error during copy: {Message}", ex.Message);
    throw;
}

Prevention

When it happens

Trigger: CopyFileAsync when GetObjectMetadataAsync throws: invalid credentials (403), missing s3 permissions, bucket in another region, network errors, throttling (503), or any non-NotFound S3 error.

Common situations: Wrong AccessKey/SecretKey, IAM policy lacks s3:GetObject/HeadObject, bucket region mismatch vs. service URL, expired credentials, transient AWS outages or rate limits.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/0ca7489226316dca. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs:215

        {
            throw new ArgumentException($"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.");
        }

        try
        {
            await _amazonS3Client.GetObjectMetadataAsync(new GetObjectMetadataRequest
            {
                BucketName = _options.BucketName,
                Key = this.Combine(_basePrefix, srcPath),
            });
        }
        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)
        {
            throw new FileStoreException($"Cannot copy file '{srcPath}' because it does not exist.");
        }
        catch (AmazonS3Exception ex)
        {
            throw new FileStoreException($"Error accessing file '{srcPath}': {ex.Message}", ex);
        }

        try
        {
            var listObjects = await _amazonS3Client.ListObjectsV2Async(new ListObjectsV2Request
            {
                BucketName = _options.BucketName,
                Prefix = this.Combine(_basePrefix, dstPath),
            });

            if (listObjects.S3Objects?.Count > 0)
            {
                throw new ExistsFileStoreException($"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.");
            }

            var copyObjectResponse = await _amazonS3Client.CopyObjectAsync(new CopyObjectRequest
            {
                SourceBucket = _options.BucketName,

View on GitHub (pinned to 4306c0717f)