Skip to content

Latest commit

 

History

History
315 lines (154 loc) · 4.24 KB

File.md

File metadata and controls

315 lines (154 loc) · 4.24 KB

SpacesAPI\File

Represents a single file

You wouldn't normally instantiate this class directly, Rather obtain an instance from \SpacesAPI\Space::list(), \SpacesAPI\Spaces::file(), \SpacesAPI\Spaces::uploadText() or \SpacesAPI\Spaces::uploadFile()

Properties

name Type Description
expiration string
e_tag string
last_modified int Last modified date as unix timestamp
content_type string THe mime type of the file
content_length int The size of the file in bytes

Methods

Name Description
__construct
copy Copy the file on the space
delete Permanently delete this file
download Download the file to a local location
getContents Get the file contents as a string
getSignedURL Get a signed URL, which will work for private files
getURL Get the public URL. This URL will not work if the file is private
isPublic Is this file publicly accessible
makePrivate Make file non-publicly accessible
makePublic Make file publicly accessible
move Move and/or rename file

File::__construct

Description

 __construct (\SpacesAPI\Space $space, string $filename, array $info = [], bool $validate = true)

Parameters

  • (\SpacesAPI\Space) $space : An instance of \SpacesAPI\Space
  • (string) $filename : The filename of a file
  • (array) $info : Any information already known about the file (eg content_length, content_type, etc). Default []
  • (bool) $validate : Check that the file exists. Default true

Return Values

void

Throws Exceptions

\SpacesAPI\Exceptions\FileDoesntExistException : If validation is true and the file doesn't exist


File::copy

Description

public copy (string $newFilename, bool $public = false)

Copy the file on the space

Parameters

  • (string) $newFilename
  • (bool) $public

Return Values

\SpacesAPI\File : An instance for the new file


File::delete

Description

public delete (void)

Permanently delete this file

Parameters

This function has no parameters.

Return Values

void


File::download

Description

public download (string $saveAs)

Download the file to a local location

Parameters

  • (string) $saveAs Then filepath including the filename. This can be a relative or absolute path.

Return Values

void


File::getContents

Description

public getContents (void)

Get the file contents as a string

Parameters

This function has no parameters.

Return Values

string


File::getSignedURL

Description

public getSignedURL (string|\DateTime|int $validFor)

Get a signed URL, which will work for private files

Parameters

  • (string|\DateTime|int) $validFor : Can be any string recognised by strtotime(), an instance of \DateTime or a unix timestamp

Return Values

string


File::getURL

Description

public getURL (void)

Get the public URL. This URL will not work if the file is private

Parameters

This function has no parameters.

Return Values

string


File::isPublic

Description

public isPublic (void)

Is this file publicly accessible?

Parameters

This function has no parameters.

Return Values

bool


File::makePrivate

Description

public makePrivate (void)

Make file non-publicly accessible

Parameters

This function has no parameters.

Return Values

void


File::makePublic

Description

public makePublic (void)

Make file publicly accessible

Parameters

This function has no parameters.

Return Values

void


File::move

Description

public move (string $newFilename)

Move or rename a file The instance of File is now the moved object

Parameters

  • (string) $newFilename

Return Values

\SpacesAPI\File : An instance for the new file