{"record":{"id":"9b47e92daaa78cf2","repo":"abpframework/abp","slug":"saving-blob-args-blobname-does-already-exists-9b47e9","errorCode":null,"errorMessage":"Saving BLOB '{args.BlobName}' does already exists in the container '{args.ContainerName}'! Set OverrideExisting if it should be overwritten.","messagePattern":"Saving BLOB '(.+?)' does already exists in the container '(.+?)'! Set OverrideExisting if it should be overwritten\\.","errorType":"exception","errorClass":"BlobAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs","lineNumber":25,"sourceCode":"\nnamespace Volo.Abp.BlobStoring.FileSystem;\n\npublic class FileSystemBlobProvider : BlobProviderBase, ITransientDependency\n{\n    protected IBlobFilePathCalculator FilePathCalculator { get; }\n\n    public FileSystemBlobProvider(IBlobFilePathCalculator filePathCalculator)\n    {\n        FilePathCalculator = filePathCalculator;\n    }\n\n    public override async Task SaveAsync(BlobProviderSaveArgs args)\n    {\n        var filePath = FilePathCalculator.Calculate(args);\n\n        if (!args.OverrideExisting && await ExistsAsync(filePath))\n        {\n            throw new BlobAlreadyExistsException($\"Saving BLOB '{args.BlobName}' does already exists in the container '{args.ContainerName}'! Set {nameof(args.OverrideExisting)} if it should be overwritten.\");\n        }\n\n        DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath)!);\n\n        var fileMode = args.OverrideExisting\n            ? FileMode.Create\n            : FileMode.CreateNew;\n\n        // A failure is only retried while it is replayable: before OpenFileStream returns\n        // (the source is untouched), or for a seekable overwrite (the source can seek back\n        // and FileMode.Create truncates the partial content). Otherwise a retry would\n        // replay a half-consumed source or hit the file a failed CreateNew attempt left behind.\n        long sourcePosition;\n        try\n        {\n            sourcePosition = args.BlobStream.CanSeek && fileMode == FileMode.Create ? args.BlobStream.Position : -1;\n        }\n        catch (Exception ex) when (ex is NotSupportedException || ex is IOException)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobProvider.cs#L7-L43","documentation":"Thrown by FileSystemBlobProvider.SaveAsync when OverrideExisting is false and a file already exists at the calculated file path (ExistsAsync returns true). It is the filesystem analogue of the cloud providers' BlobAlreadyExistsException, guarding against silent overwrites before DirectoryHelper creates the directory and the file is opened with FileMode.CreateNew.","triggerScenarios":"Saving a blob through the FileSystem provider where the file at FilePathCalculator.Calculate(args) already exists and OverrideExisting is false. The existence check uses File.Exists on the resolved path.","commonSituations":"Re-saving a file under a stable path, retrying a write that completed, persistent local storage where keys collide, or multiple app instances writing to a shared filesystem path.","solutions":["Pass overrideExisting: true to replace the existing file (the provider then uses FileMode.Create).","Use a unique blob/file name per save.","Call ExistsAsync first and branch.","Delete the existing file before re-saving if overwrite semantics are unwanted."],"exampleFix":"// before\nawait container.SaveAsync(\"data.bin\", stream);\n\n// after\nawait container.SaveAsync(\"data.bin\", stream, overrideExisting: true);","handlingStrategy":"validation","validationCode":"if (await container.ExistsAsync(blobName))\n{\n    await container.SaveAsync(blobName, stream, overrideExisting: true);\n    return;\n}\nawait container.SaveAsync(blobName, stream);","typeGuard":"bool willConflict = !args.OverrideExisting && await container.ExistsAsync(blobName);","tryCatchPattern":"try { await container.SaveAsync(blobName, stream); }\ncatch (BlobAlreadyExistsException)\n{ /* rename or retry with overrideExisting: true */ }","preventionTips":["Pass OverrideExisting when updating an existing file.","Use unique names for immutable uploads.","In multi-instance deployments on a shared filesystem, coordinate write paths to avoid races."],"tags":["blob-storage","filesystem","save","conflict","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}