pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
911 stars 319 forks source link

New command: m365 file copy #4623

Closed appieschot closed 7 months ago

appieschot commented 1 year ago

Usage

m365 file copy

Description

Copies a file to another location using the Microsoft Graph

Options

Option Description
-u, --webUrl <webUrl> The URL of the site where the file is located.
-s, --sourceUrl <sourceUrl> Server-relative or absolute URL of the file.
-t, --targetUrl <targetUrl> Server-relative or absolute URL of the location.
--newName [newName] New name of the destination file.
--nameConflictBehavior [nameConflictBehavior] Behavior when a document with the same name is already present at the destination. Possible values: fail, replace, rename. Default is fail.

Examples

Copies a file using the graph

m365 file copy--webUrl https://contoso.sharepoint.com/sites/project --sourceUrl "/sites/project/Shared Documents/Document.pdf" --targetUrl "/sites/IT/Shared Documents"

Default properties

No response

Additional Info

Adam-it commented 1 year ago

similar comment like in the move command. Do you think this could replace the m365 spo file copy command with an alias 🤔? @pnp/cli-for-microsoft-365-maintainers could we double check this one 😊

Adam-it commented 1 year ago

@appieschot i think the related/similar issue was rechecked and is opened now. Maybe we could open this one as well?

martinlingstuyl commented 1 year ago

Let's open it up 👍

Saurabh7019 commented 1 year ago
  • Validate if we already have appropriate permissions for this command

Is the requirement to check if the user executing the command has the necessary permissions in both the source and target sites and to report if not, or, also grant the permission if missing?

Adam-it commented 1 year ago
  • Validate if we already have appropriate permissions for this command

Is the requirement to check if the user executing the command has the necessary permissions in both the source and target sites and to report if not, or, also grant the permission if missing?

I would say just checking without granting.

Saurabh7019 commented 1 year ago

I am wondering if we really need this additional check or let the command throw 'access denied' error if permissions are missing. Like m365 file add/list and many other commands.

Adam-it commented 1 year ago

yep. I agree. Not really sure what @appieschot had in mind 🤔. But I say trying and if the permission is not sufficient throwing an error is good enough for me 👍

Any different opinion @pnp/cli-for-microsoft-365-maintainers ?

appieschot commented 1 year ago

@Adam-it I added that one as a note to validate if the CLI has enough permissions to do so (if we have the appropriate scope already). We do not need to have that in the command itself, just need to be sure we can call the Graph Endpoint to do so :-). I just checked and we have those permissions already: https://learn.microsoft.com/en-us/graph/api/driveitem-copy?view=graph-rest-1.0&tabs=http

Adam-it commented 1 year ago

@Saurabh7019 I guess should be no clear 👍 @appieschot thanks for the clarification

Saurabh7019 commented 1 year ago

Thank you for clarifying. Can I work on it?