From df5c39727da1e7a9d32fdeb8191044c294ec1064 Mon Sep 17 00:00:00 2001 From: Beau Cameron Date: Thu, 30 Nov 2023 16:55:28 -0500 Subject: [PATCH] Update AddUsingPath Add Missing parameter to AddUsingPath Updating Docs Adding Missing Parameter from interface. --- docs/sp/files.md | 2 ++ packages/sp/files/types.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/sp/files.md b/docs/sp/files.md index 0d7cab221..d97378989 100644 --- a/docs/sp/files.md +++ b/docs/sp/files.md @@ -134,6 +134,8 @@ Likewise you can add files using one of two methods, addUsingPath or addChunked. The addUsingPath method, supports the percent or pound characters in file names. +When using EnsureUniqueFileName property, you must omit the Overwrite parameter. + ```TypeScript import { spfi } from "@pnp/sp"; import "@pnp/sp/webs"; diff --git a/packages/sp/files/types.ts b/packages/sp/files/types.ts index e5c9d8026..b51a0207e 100644 --- a/packages/sp/files/types.ts +++ b/packages/sp/files/types.ts @@ -59,6 +59,9 @@ export class _Files extends _SPCollection { if (parameters.Overwrite) { path.push(",Overwrite=true"); } + if (parameters.EnsureUniqueFileName) { + path.push(`,EnsureUniqueFileName=${parameters.EnsureUniqueFileName}`); + } if (parameters.AutoCheckoutOnInvalidData) { path.push(",AutoCheckoutOnInvalidData=true"); } @@ -703,7 +706,7 @@ export interface IAddUsingPathProps { /** * Overwrite the file if it exists */ - Overwrite: boolean; + Overwrite?: boolean; /** * specifies whether to auto checkout on invalid Data. It'll be useful if the list contains validation whose requirements upload will not be able to meet. */ @@ -712,6 +715,10 @@ export interface IAddUsingPathProps { * Specifies a XOR hash of the file data which should be used to ensure end-2-end data integrity, base64 representation */ XorHash?: string; + /** + * Specifies whether to force unique file name. When using this, omit the Overwrite parameter. + */ + EnsureUniqueFileName?: boolean; } export interface IFileInfo {