Skip to content

Spo file copy updated - #705

Closed
simonagren wants to merge 6 commits into
pnp:devfrom
simonagren:spo-file-copy
Closed

simonagren wants to merge 6 commits into
pnp:devfrom
simonagren:spo-file-copy

Conversation

@simonagren

Copy link
Copy Markdown
Member

Made a few changes to match the changes made in spo file move and spo folder move

  • Added AllowSchemaMismatch
  • Changed to url.resolve
  • single parsing of URL
  • Empty return in Promise function
  • Slight changed in unit tests
  • Slight change in documentation
@coveralls

coveralls commented Dec 10, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f21b904 on simonagren:spo-file-copy into 8270091 on pnp:dev.

@waldekmastykarz

Copy link
Copy Markdown
Member

Thank you! I'll review it shortly

@waldekmastykarz waldekmastykarz self-assigned this Dec 11, 2018

@waldekmastykarz waldekmastykarz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When trying to use the command, I'm getting a File not found error.

Repro:

spo file copy -u https://contoso.sharepoint.com/sites/marketing -s /Shared%20Documents/BrandingElements.png -t /sites/sales/Shared%20Documents

It seems that the command generated invalid URL in the CreateCopyJobs payload:

CreateCopyJobs request...
body   : {"exportObjectUris":["https://contoso.sharepoint.com/sites/Shared%20Documents/BrandingElements.png"],"destinationUri":"https://contoso.sharepoint.com/sites/sales/Shared%20Documents","options":{"AllowSchemaMismatch":false,"IgnoreVersionHistory":true}}
headers: {"authorization":"Bearer eyJ0eXAiOiJKV1QiLCJhbGc...","accept":"application/json;odata=nometadata","User-Agent":"NONISV|SharePointPnP|Office365CLI/1.11.0"}
json   : true
url    : https://contoso.sharepoint.com/sites/marketing/_api/site/CreateCopyJobs

I also tried running

spo file copy -u https://contoso.sharepoint.com/sites/marketing -s Shared%20Documents/BrandingElements.png -t /sites/sales/Shared%20Documents

and

spo file copy -u https://contoso.sharepoint.com/sites/marketing -s "/Shared Documents/BrandingElements.png" -t /sites/sales/Shared%20Documents

But in all cases I'm getting the same error

@waldekmastykarz waldekmastykarz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done with a few things I've fixed when merging the PR

sourceUrl: string;
targetUrl: string;
deleteIfAlreadyExists?: boolean;
allowSchemaMismatch: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowSchemaMismatch should be optional

`-t, --targetUrl <targetUrl>`|Server-relative URL where to copy the file
`--deleteIfAlreadyExists`|If a file already exists at the targetUrl, it will be moved to the recycle bin. If omitted, the copy operation will be canceled if the file already exists at the targetUrl location
`--deleteIfAlreadyExists`|If a file already exists at the targetUrl, it will be moved to the recycle bin. If omitted, the copy
operation will be canceled if the file already exists at the targetUrl location

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking lines in a table in MD breaks formatting creating a new row. Instead, the whole description should be in one line

```

Copy file to a document library in another site collection. Allow for schema mismatch
```sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an empty line between the text and code block. Additionally, the code block shouldn't be indented

spo file copy --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/sp1.pdf --targetUrl /sites/test2/Shared%20Documents/ --deleteIfAlreadyExists
```

Copy file to a document library in another site collection. Allow for schema mismatch

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This content is different from the help included in command. Both should be the same

@waldekmastykarz waldekmastykarz added this to the v1.13.0 milestone Dec 30, 2018
@waldekmastykarz

Copy link
Copy Markdown
Member

Merged manually. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants