Download the PHP package ernestmarcinko/waifuvault-php-api without Composer
On this page you can find all versions of the php package ernestmarcinko/waifuvault-php-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ernestmarcinko/waifuvault-php-api
More information about ernestmarcinko/waifuvault-php-api
Files in ernestmarcinko/waifuvault-php-api
Package waifuvault-php-api
Short Description SDK to interact with WaifuVault, a temporary file hosting service
License MIT
Informations about the package waifuvault-php-api
waifuvault-php-api
This contains the official API bindings for uploading, deleting and obtaining files with waifuvault.moe. Contains a full up-to-date API for interacting with the service via PHP
Installation via Composer
Usage
This API contains 4 interactions:
- Upload File
- Get File Info
- Delete File
- Get File
- Modify Entry
The only class needed is the WaifuApi
class from ErnestMarcinko\WaifuVault
:
Upload File
To Upload a file, use the WaifuApi::uploadFile
function.
Parameters
The function accepts an associative array of arguments.
Param (key) | Type | Description | Required | Extra info |
---|---|---|---|---|
file |
string |
The file path to upload | true only if url or file_contents is not supplied |
If url is supplied, this prop can't be set |
url |
string |
The URL to a file that exists on the internet | true only if file or file_contents is not supplied |
If url is supplied, this prop has no effect |
file_contents |
string |
The file contents | true only if url or file is not supplied |
If url or file is supplied, this prop can't be set |
expires |
string |
A string containing a number and a unit (1d = 1day) | false | Valid units are m , h and d |
hideFilename |
boolean |
If true, then the uploaded filename won't appear in the URL | false | Defaults to false |
password |
string |
If set, then the uploaded file will be encrypted | false | |
filename |
string |
Only used if file_contents or file is set, will set the filename of the upload |
false | |
oneTimeDownload |
boolean |
If true, the file is deleted after the first access | false |
WaifuResponse Return value
The function returns a WaifuResponse
object, throws and Exception
or WaifuException
. Almost all SDK functions will use this object as their return values.
Examples
Using a URL:
Using a file path:
Using a file contents:
Get File Info
The WaifuApi::getFileInfo
function is used to get the file information.
Parameters
Param | Type | Description | Required | Extra info |
---|---|---|---|---|
token |
string |
The token of the upload | true | |
formatted |
boolean |
If you want the retentionPeriod to be human-readable or an epoch |
false | defaults to false |
Return value
WaifuApi::getFileInfo
returns a WaifuResponse
Examples
Human-readable timestamp retention period:
Delete File
The WaifuApi::deleteEntry
function is used to get the file information.
Parameters
Param | Type | Description | Required | Extra info |
---|---|---|---|---|
token |
string |
The token of the file you wish to delete | true |
Return values
NOTE:
deleteFile
will only ever either returntrue
or throw an exception if the token is invalid
Examples
Get File
The WaifuApi::getFile
function is used to get the file contents from the server by supplying either the token or the unique identifier
of the file (epoch/filename).
Parameters
The function accepts an associative array of arguments.
Param (key) | Type | Description | Required | Extra info |
---|---|---|---|---|
token |
string |
The token of the file you want to download | true only if filename is not set |
if filename is set, then this can not be used |
filename |
string |
The Unique identifier of the file, this is the epoch time stamp it was uploaded and the filename | true only if token is not set |
if token is set, then this can not be used |
password |
string |
The password for the file if it is protected | false | Must be supplied if the file is uploaded with password |
Important! The Unique identifier filename is the epoch/filename only if the file uploaded did not have a hidden filename, if it did, then it's just the epoch. For example:
1710111505084/08.png
is the Unique identifier for a standard upload of a file called08.png
, if this was uploaded with hidden filename, then it would be1710111505084.png
Return value
The function returns the file contents.
Examples
Obtain an encrypted file
Obtain a file from Unique identifier
Modify Entry
The WaifuApi::modifyEntry
is used to modify aspects of your entry such as password, removing password, decrypting the file, encrypting the
file, changing the expiry, etc.
Parameters
The function accepts an associative array of arguments.
Option | Type | Description | Required | Extra info |
---|---|---|---|---|
token |
string |
The token of the file you want to modify | true | |
password |
string |
The new password or the password you want to use to encrypt the file | false | |
previousPassword |
string |
If the file is currently protected or encrpyted and you want to change it, use this for the old password | true only if password is set and the file is currently protected |
if the file is protected already and you want to change the password, this MUST be set |
customExpiry |
string |
a new custom expiry, see expires in uploadFile |
false | |
hideFilename |
boolean |
make the filename hidden | false | for the new URL, check the response URL prop |
Return value
WaifuApi::getFileInfo
returns a WaifuResponse
Examples
Set a password on a non-encrypted file:
Change a password:
change expire:
decrypt a file and remove the password:
Custom Request Handler
The WaifuApi object can be instantiated with a custom RequestHandler (implementing RequestHandler interface). The built in request handler uses CURL.
Default Request Handler
When isntantiating the class without any parameters the default request handler is used.
Making your custom request handler
If you prefer your own methods to handle requests, you can create your own class and pass it on to the WaifuApi
constructor.
The class must implement the ErnestMarcinko\WaifuVault\RequestHandler
interface.
Then use it via DI: