Page MenuHomePhorge
Diviner Arcanist Tech Docs ArcanistFileUploader

final class ArcanistFileUploader
Arcanist Technical Documentation ()

Upload a list of ArcanistFileDataRef objects over Conduit.

// Create a new uploader.
$uploader = id(new ArcanistFileUploader())
  ->setConduitEngine($conduit);

// Queue one or more files to be uploaded.
$file = id(new ArcanistFileDataRef())
  ->setName('example.jpg')
  ->setPath('/path/to/example.jpg');
$uploader->addFile($file);

// Upload the files.
$files = $uploader->uploadFiles();

For details about building file references, see ArcanistFileDataRef.

Tasks

Configuring the Uploader

No methods for this task.

Adding Files

  • public function addFile($file, $key) — Add a file to the list of files to be uploaded.

Uploading Files

  • public function uploadFiles() — Upload files to the server.

Internals

  • private function uploadChunks($file, $file_phid) — Upload missing chunks of a large file by calling `file.uploadchunk` over Conduit.
  • private function uploadData($file) — Upload an entire file by calling `file.upload` over Conduit.
  • private function writeStatus($message) — Write a status message.

Other Methods

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function setConduitEngine($engine)

This method is not documented.
Parameters
ArcanistConduitEngine$engine
Return
wild

public function addFile($file, $key)

Add a file to the list of files to be uploaded.

You can optionally provide an explicit key which will be used to identify the file. After adding files, upload them with uploadFiles().

Parameters
ArcanistFileDataRef$fileFile data to upload.
null|string$keyOptional key to use to identify this file.
Return
this

public function uploadFiles()

Upload files to the server.

This transfers all files which have been queued with addFiles() over the Conduit link configured with setConduitEngine().

This method returns a map of all file data references. If references were added with an explicit key when addFile() was called, the key is retained in the result map.

On return, files are either populated with a PHID (indicating a successful upload) or a list of errors. See ArcanistFileDataRef for details.

Return
map<string, ArcanistFileDataRef>Files with results populated.

private function uploadChunks($file, $file_phid)

Upload missing chunks of a large file by calling file.uploadchunk over Conduit.

Parameters
ArcanistFileDataRef$file
$file_phid
Return
wild

private function uploadData($file)

Upload an entire file by calling file.upload over Conduit.

Parameters
ArcanistFileDataRef$file
Return
wild

private function getUploadParameters($file)

Get common parameters for file uploads.

Parameters
ArcanistFileDataRef$file
Return
wild

private function writeStatus($message)

Write a status message.

Parameters
$message
Return
wild