Share via


SP.File object

Represents a file in a SharePoint Web site that can be a Web Part Page, an item in a document library, or a file in a folder.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.File()

Members

The File object has the following members.

Constructor

The File object has the following constructor.

Constructor

Description

File

Initializes a new instance of the SP.File object.

Methods

The File object has the following methods.

Method

Description

approve

Approves the file submitted for content approval with the specified comment.

checkIn

Checks the file in to a document library based on the check-in type.

checkOut

Checks out the file from a document library based on the check-out type.

copyTo

Copies the file to the destination URL.

deleteObject

Deletes the File object.

deny

Denies approval for a file that was submitted for content approval.

getContentVerFromTag

Reserved for internal use only. This method exposes the internal ContentVersion value inside of a ContentTag.

getLimitedWebPartManager

Specifies the control set used to access, modify, or add Web Parts associated with this Web Part Page and view.

moveTo

Moves the file to the specified destination URL.

publish

Submits the file for content approval with the specified comment.

recycle

Moves the file to the Recycle Bin and returns the identifier of the new Recycle Bin item.

saveBinary

undoCheckOut

Reverts an existing checkout for the file.

unPublish

Removes the file from content approval or unpublish a major version.

Properties

The File object has the following properties.

Property

Description

author

Gets a value that specifies the user who added the file.

checkedOutByUser

Gets a value that returns the user who has checked out the file.

checkInComment

Gets a value that returns the comment used when a document is checked in to a document library.

checkOutType

Gets a value that indicates how the file is checked out of a document library.

contentTag

Returns internal version of content, used to validate document equality for read purposes.

customizedPageStatus

Gets a value that specifies the customization status of the file.

eTag

Gets a value that specifies the ETag value.

exists

Gets a value that specifies whether the file exists.

length

Gets the size of the file in bytes, excluding the size of any Web Parts that are used in the file.

level

Gets a value that specifies the publishing level of the file.

listItemAllFields

Gets a value that specifies the list item field values for the list item corresponding to the file.

lockedByUser

Gets a value that returns the user that owns the current lock on the file.

majorVersion

Gets a value that specifies the major version of the file.

minorVersion

Gets a value that specifies the minor version of the file.

modifiedBy

Gets a value that returns the user who last modified the file.

name

Gets the name of the file including the extension.

serverRelativeUrl

Gets the relative URL of the file based on the URL for the server.

timeCreated

Gets a value that specifies when the file was created.

timeLastModified

Gets a value that specifies when the file was last modified.

title

Gets a value that specifies the display name of the file.

uiVersion

Gets a value that specifies the implementation-specific version identifier of the file.

uiVersionLabel

Gets a value that specifies the implementation-specific version identifier of the file.

versions

Gets a value that returns a collection of file version objects that represent the versions of the file.

REST resource endpoint

See File resource for more information.

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)

HTTP requests

This resource supports the following HTTP commands:

DELETE syntax

DELETE http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)

POST syntax

POST http://<sitecollection>/<site>/_api/web/folders/getbyurl(folderrelativeurl)/files/getbyurl(filerelativeurl)