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()
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 |
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 |
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. Defaulttrue
Return Values
void
Throws Exceptions
\SpacesAPI\Exceptions\FileDoesntExistException
: If validation is true
and the file doesn't exist
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
Description
public delete (void)
Permanently delete this file
Parameters
This function has no parameters.
Return Values
void
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
Description
public getContents (void)
Get the file contents as a string
Parameters
This function has no parameters.
Return Values
string
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
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
Description
public isPublic (void)
Is this file publicly accessible?
Parameters
This function has no parameters.
Return Values
bool
Description
public makePrivate (void)
Make file non-publicly accessible
Parameters
This function has no parameters.
Return Values
void
Description
public makePublic (void)
Make file publicly accessible
Parameters
This function has no parameters.
Return Values
void
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