From 293786bfd35a96b42c2d34710c2c044bd657da00 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 27 May 2025 07:49:53 +0200 Subject: [PATCH 1/3] Add clarifying detail to documentation about UniqueMediaScheme Further to conversation in https://github.com/umbraco/Umbraco-CMS/issues/19377 --- 16/umbraco-cms/extending/filesystemproviders/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/16/umbraco-cms/extending/filesystemproviders/README.md b/16/umbraco-cms/extending/filesystemproviders/README.md index 18b491480c0..0d9bcf31404 100644 --- a/16/umbraco-cms/extending/filesystemproviders/README.md +++ b/16/umbraco-cms/extending/filesystemproviders/README.md @@ -140,11 +140,17 @@ You can then access the configured file system provider through `_mediaFileManag The MediaPath Scheme defines the current set of rules that decide the format of the Media Path when it is saved into the media archive wherever it is located. -By default the MediaPath scheme used by Umbraco is the `UniqueMediaPathScheme` this generates a unique 'folder' to place the uploaded image in eg. +By default the MediaPath scheme used by Umbraco is the `UniqueMediaPathScheme` this generates a 'folder' to place the uploaded image in, for example: `/media/dozdrg2f/mylovelyimage.jpg` -`/media` is defined by the PhysicalFileSystem and 'dozdrg2f' is generated by the `UniqueMediaPathScheme`. +`/media` is defined by the PhysicalFileSystem and `dozdrg2f` is generated by the `UniqueMediaPathScheme`. + +{% hint style="info" %} +The folder generated by `UniqueMediaPathScheme` is not strictly unique, as it's based on the first eight characters of the GUID for the media item. In practice, with randomly generated GUIDs, a collision is very unlikely. + +There is an increased possibility of generating colliding paths if creating media programmatically and setting keys using version 7 "ordered" GUIDs via `Guid.CreateVersion7()`. As such these should be avoided - `UniqueMediaPathScheme` will throw an exception if it detects they have been used. Any manually created keys should use `Guid.NewGuid()`. +{% endhint %} You can create your own logic for the path by implementing `IMediaPathScheme` and setting it during composition with: From d146ef920d947af7c78308004e4ce5ef3c595dd3 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 27 May 2025 07:55:26 +0200 Subject: [PATCH 2/3] Linting --- 16/umbraco-cms/extending/filesystemproviders/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/extending/filesystemproviders/README.md b/16/umbraco-cms/extending/filesystemproviders/README.md index 0d9bcf31404..6cfee6a66cb 100644 --- a/16/umbraco-cms/extending/filesystemproviders/README.md +++ b/16/umbraco-cms/extending/filesystemproviders/README.md @@ -147,7 +147,7 @@ By default the MediaPath scheme used by Umbraco is the `UniqueMediaPathScheme` t `/media` is defined by the PhysicalFileSystem and `dozdrg2f` is generated by the `UniqueMediaPathScheme`. {% hint style="info" %} -The folder generated by `UniqueMediaPathScheme` is not strictly unique, as it's based on the first eight characters of the GUID for the media item. In practice, with randomly generated GUIDs, a collision is very unlikely. +The folder generated by `UniqueMediaPathScheme` is not strictly unique, as it's based on the first eight characters of the GUID for the media item. In practice, with randomly generated GUIDs, a collision is unlikely. There is an increased possibility of generating colliding paths if creating media programmatically and setting keys using version 7 "ordered" GUIDs via `Guid.CreateVersion7()`. As such these should be avoided - `UniqueMediaPathScheme` will throw an exception if it detects they have been used. Any manually created keys should use `Guid.NewGuid()`. {% endhint %} From d15008754127c2b3f4784db63b7a32b4a2112a52 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 27 May 2025 13:13:29 +0200 Subject: [PATCH 3/3] Update 16/umbraco-cms/extending/filesystemproviders/README.md Co-authored-by: Esha Noronha <82437098+eshanrnh@users.noreply.github.com> --- 16/umbraco-cms/extending/filesystemproviders/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-cms/extending/filesystemproviders/README.md b/16/umbraco-cms/extending/filesystemproviders/README.md index 6cfee6a66cb..6729158859a 100644 --- a/16/umbraco-cms/extending/filesystemproviders/README.md +++ b/16/umbraco-cms/extending/filesystemproviders/README.md @@ -149,7 +149,7 @@ By default the MediaPath scheme used by Umbraco is the `UniqueMediaPathScheme` t {% hint style="info" %} The folder generated by `UniqueMediaPathScheme` is not strictly unique, as it's based on the first eight characters of the GUID for the media item. In practice, with randomly generated GUIDs, a collision is unlikely. -There is an increased possibility of generating colliding paths if creating media programmatically and setting keys using version 7 "ordered" GUIDs via `Guid.CreateVersion7()`. As such these should be avoided - `UniqueMediaPathScheme` will throw an exception if it detects they have been used. Any manually created keys should use `Guid.NewGuid()`. +There is an increased possibility of generating colliding paths if creating media programmatically and setting keys using version 7 "ordered" GUIDs via `Guid.CreateVersion7()`. As such these should be avoided. `UniqueMediaPathScheme` will throw an exception if it detects they have been used. Any manually created keys should use `Guid.NewGuid()`. {% endhint %} You can create your own logic for the path by implementing `IMediaPathScheme` and setting it during composition with: