Index

Uploads

MMO\edms\helpers · 1 symbol · generated 5 Oct 2026

class

Uploads

Uploads.php:18

The uploads in progress, in a folder of their own ($folder), which only the server's account reads: the server keeps what an upload is and where its bytes are, a client only knows the upload's id. A chunk is only taken where the previous one stopped, and never past the size the upload started with. An upload that made its file remembers it until it expires, so a client that did not hear the answer to its last chunk gets it again.

class MMO\edms\helpers\Uploads
Namespace
MMO\edms\helpers
$uploads = new Uploads('/tmp/mmo.edms'); $upload = $uploads->start($user, 'report.pdf', 1048576); $uploads->append($upload, 0, $chunk);

Index

folder readonly
append($upload, $offset, $bytes)Append $bytes to the upload, where it stopped
finish($upload, $fileId)The upload made the file $fileId: it remembers it, its bytes are the file's now
get($id)
getOf($id, $client)
loopExpired($time)The uploads nothing was received for since $time: those the garbage collector deletes
metaFilename($id)
remove($upload)Forget the upload, deleting its bytes
start($owner, $name, $size, $labels, $attachment, $temporary)Start an upload of $size bytes
take($upload)Take the bytes of a complete upload: the upload is forgotten, the file it returns is the caller's to move or delete
write($filename, $content)Write $content to $filename, which only the server's account reads
__construct($folder)

Properties1

folder

readonly
readonly string $folder
Type
string

Methods11

append($upload, $offset, $bytes)

Uploads.php:77

Append $bytes to the upload, where it stopped

function append(MMO\edms\helpers\Upload $upload, int $offset, string $bytes): int
$uploadUpload
$offsetintwhere $bytes go: the number of bytes already received
$bytesstring
returnsintthe number of bytes received, $bytes included
throws(409) if $offset is not where the upload stopped, (413) if $bytes go past its size

finish($upload, $fileId)

Uploads.php:54

The upload made the file $fileId: it remembers it, its bytes are the file's now

function finish(MMO\edms\helpers\Upload $upload, mixed $fileId): MMO\edms\helpers\Upload
$uploadUpload
$fileIdmixed
returnsUploadthe upload, finished

getOf($id, $client)

Uploads.php:65
function getOf(string $id, MMO\oauth\interfaces\iClient $client): MMO\edms\helpers\Upload
$idstring
$clientiClient
returnsUploadthe upload $id of $client
throws(404) if $client has no such upload: another's is not found either

loopExpired($time)

Uploads.php:126

The uploads nothing was received for since $time: those the garbage collector deletes

function loopExpired(int $time): Generator
$timeint
returnsGenerator

remove($upload)

Uploads.php:104

Forget the upload, deleting its bytes

function remove(MMO\edms\helpers\Upload $upload): void
$uploadUpload
returnsvoid

start($owner, $name, $size, $labels, $attachment, $temporary)

Uploads.php:29

Start an upload of $size bytes

function start( MMO\oauth\interfaces\iClient $owner, string $name, int $size, array $labels = [], ?string $attachment = null, bool $temporary = false ): MMO\edms\helpers\Upload
$owneriClient
$namestring
$sizeint
$labels = []arraythe ids of the labels the file will carry
$attachment = nullnull | string
$temporary = falsebool
returnsUpload

take($upload)

Uploads.php:115

Take the bytes of a complete upload: the upload is forgotten, the file it returns is the caller's to move or delete

function take(MMO\edms\helpers\Upload $upload): string
$uploadUpload
returnsstringthe local file
throws(409) if the upload is not complete

write($filename, $content)

Uploads.php:138

Write $content to $filename, which only the server's account reads

protected function write(string $filename, string $content): void
$filenamestring
$contentstring
returnsvoid

__construct($folder)

Uploads.php:22
function __construct(string $folder)
$folderstringwhere the uploads are kept (created if needed)