import { SharePointQueryable, SharePointQueryableCollection, SharePointQueryableInstance } from "./sharepointqueryable"; import { LimitedWebPartManager } from "./webparts"; import { Item } from "./items"; import { SharePointQueryableShareableFile } from "./sharepointqueryableshareable"; export interface ChunkedFileUploadProgressData { uploadId: string; stage: "starting" | "continue" | "finishing"; blockNumber: number; totalBlocks: number; chunkSize: number; currentPointer: number; fileSize: number; } /** * Describes a collection of File objects * */ export declare class Files extends SharePointQueryableCollection { /** * Creates a new instance of the Files class * * @param baseUrl The url or SharePointQueryable which forms the parent of this fields collection */ constructor(baseUrl: string | SharePointQueryable, path?: string); /** * Gets a File by filename * * @param name The name of the file, including extension. */ getByName(name: string): File; /** * Uploads a file. Not supported for batching * * @param url The folder-relative url of the file. * @param content The file contents blob. * @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true) * @returns The new File and the raw response. */ add(url: string, content: string | ArrayBuffer | Blob, shouldOverWrite?: boolean): Promise; /** * Uploads a file. Not supported for batching * * @param url The folder-relative url of the file. * @param content The Blob file content to add * @param progress A callback function which can be used to track the progress of the upload * @param shouldOverWrite Should a file with the same name in the same location be overwritten? (default: true) * @param chunkSize The size of each file slice, in bytes (default: 10485760) * @returns The new File and the raw response. */ addChunked(url: string, content: Blob, progress?: (data: ChunkedFileUploadProgressData) => void, shouldOverWrite?: boolean, chunkSize?: number): Promise; /** * Adds a ghosted file to an existing list or document library. Not supported for batching. * * @param fileUrl The server-relative url where you want to save the file. * @param templateFileType The type of use to create the file. * @returns The template file that was added and the raw response. */ addTemplateFile(fileUrl: string, templateFileType: TemplateFileType): Promise; } /** * Describes a single File instance * */ export declare class File extends SharePointQueryableShareableFile { /** * Gets a value that specifies the list item field values for the list item corresponding to the file. * */ readonly listItemAllFields: SharePointQueryableCollection; /** * Gets a collection of versions * */ readonly versions: Versions; /** * Approves the file submitted for content approval with the specified comment. * Only documents in lists that are enabled for content approval can be approved. * * @param comment The comment for the approval. */ approve(comment?: string): Promise; /** * Stops the chunk upload session without saving the uploaded data. Does not support batching. * If the file doesn’t already exist in the library, the partially uploaded file will be deleted. * Use this in response to user action (as in a request to cancel an upload) or an error or exception. * Use the uploadId value that was passed to the StartUpload method that started the upload session. * This method is currently available only on Office 365. * * @param uploadId The unique identifier of the upload session. */ cancelUpload(uploadId: string): Promise; /** * Checks the file in to a document library based on the check-in type. * * @param comment A comment for the check-in. Its length must be <= 1023. * @param checkinType The check-in type for the file. */ checkin(comment?: string, checkinType?: CheckinType): Promise; /** * Checks out the file from a document library. */ checkout(): Promise; /** * Copies the file to the destination url. * * @param url The absolute url or server relative url of the destination file path to copy to. * @param shouldOverWrite Should a file with the same name in the same location be overwritten? */ copyTo(url: string, shouldOverWrite?: boolean): Promise; /** * Delete this file. * * @param eTag Value used in the IF-Match header, by default "*" */ delete(eTag?: string): Promise; /** * Denies approval for a file that was submitted for content approval. * Only documents in lists that are enabled for content approval can be denied. * * @param comment The comment for the denial. */ deny(comment?: string): Promise; /** * Specifies the control set used to access, modify, or add Web Parts associated with this Web Part Page and view. * An exception is thrown if the file is not an ASPX page. * * @param scope The WebPartsPersonalizationScope view on the Web Parts page. */ getLimitedWebPartManager(scope?: WebPartsPersonalizationScope): LimitedWebPartManager; /** * Moves the file to the specified destination url. * * @param url The absolute url or server relative url of the destination file path to move to. * @param moveOperations The bitwise MoveOperations value for how to move the file. */ moveTo(url: string, moveOperations?: MoveOperations): Promise; /** * Submits the file for content approval with the specified comment. * * @param comment The comment for the published file. Its length must be <= 1023. */ publish(comment?: string): Promise; /** * Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item. * * @returns The GUID of the recycled file. */ recycle(): Promise; /** * Reverts an existing checkout for the file. * */ undoCheckout(): Promise; /** * Removes the file from content approval or unpublish a major version. * * @param comment The comment for the unpublish operation. Its length must be <= 1023. */ unpublish(comment?: string): Promise; /** * Gets the contents of the file as text. Not supported in batching. * */ getText(): Promise; /** * Gets the contents of the file as a blob, does not work in Node.js. Not supported in batching. * */ getBlob(): Promise; /** * Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching. */ getBuffer(): Promise; /** * Gets the contents of a file as an ArrayBuffer, works in Node.js. Not supported in batching. */ getJSON(): Promise; /** * Sets the content of a file, for large files use setContentChunked. Not supported in batching. * * @param content The file content * */ setContent(content: string | ArrayBuffer | Blob): Promise; /** * Gets the associated list item for this folder, loading the default properties */ getItem(...selects: string[]): Promise; /** * Sets the contents of a file using a chunked upload approach. Not supported in batching. * * @param file The file to upload * @param progress A callback function which can be used to track the progress of the upload * @param chunkSize The size of each file slice, in bytes (default: 10485760) */ setContentChunked(file: Blob, progress?: (data: ChunkedFileUploadProgressData) => void, chunkSize?: number): Promise; /** * Starts a new chunk upload session and uploads the first fragment. * The current file content is not changed when this method completes. * The method is idempotent (and therefore does not change the result) as long as you use the same values for uploadId and stream. * The upload session ends either when you use the CancelUpload method or when you successfully * complete the upload session by passing the rest of the file contents through the ContinueUpload and FinishUpload methods. * The StartUpload and ContinueUpload methods return the size of the running total of uploaded data in bytes, * so you can pass those return values to subsequent uses of ContinueUpload and FinishUpload. * This method is currently available only on Office 365. * * @param uploadId The unique identifier of the upload session. * @param fragment The file contents. * @returns The size of the total uploaded data in bytes. */ protected startUpload(uploadId: string, fragment: ArrayBuffer | Blob): Promise; /** * Continues the chunk upload session with an additional fragment. * The current file content is not changed. * Use the uploadId value that was passed to the StartUpload method that started the upload session. * This method is currently available only on Office 365. * * @param uploadId The unique identifier of the upload session. * @param fileOffset The size of the offset into the file where the fragment starts. * @param fragment The file contents. * @returns The size of the total uploaded data in bytes. */ protected continueUpload(uploadId: string, fileOffset: number, fragment: ArrayBuffer | Blob): Promise; /** * Uploads the last file fragment and commits the file. The current file content is changed when this method completes. * Use the uploadId value that was passed to the StartUpload method that started the upload session. * This method is currently available only on Office 365. * * @param uploadId The unique identifier of the upload session. * @param fileOffset The size of the offset into the file where the fragment starts. * @param fragment The file contents. * @returns The newly uploaded file. */ protected finishUpload(uploadId: string, fileOffset: number, fragment: ArrayBuffer | Blob): Promise; } /** * Describes a collection of Version objects * */ export declare class Versions extends SharePointQueryableCollection { /** * Creates a new instance of the File class * * @param baseUrl The url or SharePointQueryable which forms the parent of this fields collection */ constructor(baseUrl: string | SharePointQueryable, path?: string); /** * Gets a version by id * * @param versionId The id of the version to retrieve */ getById(versionId: number): Version; /** * Deletes all the file version objects in the collection. * */ deleteAll(): Promise; /** * Deletes the specified version of the file. * * @param versionId The ID of the file version to delete. */ deleteById(versionId: number): Promise; /** * Recycles the specified version of the file. * * @param versionId The ID of the file version to delete. */ recycleByID(versionId: number): Promise; /** * Deletes the file version object with the specified version label. * * @param label The version label of the file version to delete, for example: 1.2 */ deleteByLabel(label: string): Promise; /** * REcycles the file version object with the specified version label. * * @param label The version label of the file version to delete, for example: 1.2 */ recycleByLabel(label: string): Promise; /** * Creates a new file version from the file specified by the version label. * * @param label The version label of the file version to restore, for example: 1.2 */ restoreByLabel(label: string): Promise; } /** * Describes a single Version instance * */ export declare class Version extends SharePointQueryableInstance { /** * Delete a specific version of a file. * * @param eTag Value used in the IF-Match header, by default "*" */ delete(eTag?: string): Promise; /** * Opens the file as a stream. */ openBinaryStream(): Promise; } export declare enum CheckinType { Minor = 0, Major = 1, Overwrite = 2, } export interface FileAddResult { file: File; data: any; } export declare enum WebPartsPersonalizationScope { User = 0, Shared = 1, } export declare enum MoveOperations { Overwrite = 1, AllowBrokenThickets = 8, } export declare enum TemplateFileType { StandardPage = 0, WikiPage = 1, FormPage = 2, ClientSidePage = 3, }