Page MenuHomePhabricator
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 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