Skip to content

Commit

Permalink
Fix docs for SP Files
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie Turner committed Aug 12, 2024
1 parent efec1c4 commit ef0c494
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions docs/sp/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ if (file.size <= 10485760) {
result = await sp.web.getFolderByServerRelativePath("Shared Documents").files.addUsingPath(fileNamePath, file, { Overwrite: true });
} else {
// large upload
result = await sp.web.getFolderByServerRelativePath("Shared Documents").files.addChunked(fileNamePath, file, data => {
console.log(`progress`);
}, true);
result = await sp.web.getFolderByServerRelativePath("Shared Documents").files.addChunked(fileNamePath, file,
{ progress: data => { console.log(`progress`); },
Overwrite: true
}
);
}

console.log(`Result of file upload: ${JSON.stringify(result)}`);
Expand Down Expand Up @@ -186,7 +188,7 @@ const stream = createReadStream("c:/temp/file.txt");
// now add the stream as a new file
const sp = spfi(...);

const fr = await sp.web.lists.getByTitle("Documents").rootFolder.files.addChunked( "new.txt", stream, undefined, true );
const fileInfo = await sp.web.lists.getByTitle("Documents").rootFolder.files.addChunked("new.txt", stream, { progress: data => { console.log(`progress`); }, Overwrite: true });
```

### Setting Associated Item Values
Expand All @@ -200,7 +202,7 @@ import "@pnp/sp/files";
import "@pnp/sp/folders";

const sp = spfi(...);
const file = await sp.web.getFolderByServerRelativePath("/sites/dev/Shared%20Documents/test/").files.addUsingPath("file.name", "content", {Overwrite: true});
const fileInfo = await sp.web.getFolderByServerRelativePath("/sites/dev/Shared%20Documents/test/").files.addUsingPath("file.name", "content", {Overwrite: true});
const item = await file.file.getItem();
await item.update({
Title: "A Title",
Expand Down Expand Up @@ -560,4 +562,3 @@ import "@pnp/sp/files";
const sp = spfi(...);
const user = await sp.web.getFolderByServerRelativePath("{folder relative path}").files.getByUrl("name.txt").getLockedByUser();
```

0 comments on commit ef0c494

Please sign in to comment.