Skip to content

Commit 334950b

Browse files
authored
Merge pull request #706 from wilecoyotegenius/add-filesize-to-filepicker
Add filesize to FilePicker component
2 parents 8b644b5 + 918e74d commit 334950b

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

docs/documentation/docs/controls/FilePicker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Provides options for carousel buttons location.
8686
| fileName | string | File name of the result with the extension. |
8787
| fileNameWithoutExtension | string | File name of the result without the extension. |
8888
| fileAbsoluteUrl | string | Absolute URL of the file. Null in case of file upload. |
89+
| fileSize | number | Size of the result (in bytes). Set only for file upload |
8990
| downloadFileContent | () => Promise<File> | Function allows to download file content. Returns File object. |
9091

9192

src/controls/filePicker/FilePicker.types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export interface IFilePickerResult {
3232
*/
3333
fileAbsoluteUrl: string;
3434

35+
/**
36+
* Size of a selected file (in bytes). Undefined in all cases but file upload
37+
*/
38+
fileSize?: number;
39+
3540
/**
3641
* Absolute not modified file SharePoint URL.
3742
*/

src/controls/filePicker/UploadFilePickerTab/UploadFilePickerTab.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class UploadFilePickerTab extends React.Component<IUploadFilePick
8181
const filePickerResult: IFilePickerResult = {
8282
fileAbsoluteUrl: null,
8383
fileName: file.name,
84+
fileSize: file.size,
8485
fileNameWithoutExtension: GeneralHelper.getFileNameWithoutExtension(file.name),
8586
downloadFileContent: () => { return Promise.resolve(file); }
8687
};

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,12 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
12791279
{
12801280
this.state.filePickerResult &&
12811281
<div>
1282-
FileName: {this.state.filePickerResult.fileName}
1282+
<div>
1283+
FileName: {this.state.filePickerResult.fileName}
1284+
</div>
1285+
<div>
1286+
File size: {this.state.filePickerResult.fileSize}
1287+
</div>
12831288
</div>
12841289
}
12851290
</div>

0 commit comments

Comments
 (0)