Tripal
Functions
tripal.upload.api.php File Reference

Functions

 hook_file_upload_check ($action, $details, &$message)
 
 tripal_file_upload ($type, $filename, $action=NULL, $chunk=0)
 
 tripal_file_upload_post ($filename, $chunk, $user_dir)
 
 tripal_file_upload_read_log ($temp_dir)
 
 tripal_file_upload_write_log ($temp_dir, $log)
 
 tripal_file_upload_verify ($filename, $chunk, $user_dir)
 
 tripal_file_upload_merge ($filename, $type, $user_dir)
 

Detailed Description

Provides an application programming interface (API) for working with file uploads.

Function Documentation

◆ tripal_file_upload_merge()

tripal_file_upload_merge (   $filename,
  $type,
  $user_dir 
)

Merges all chunks into a single file

◆ tripal_file_upload_post()

tripal_file_upload_post (   $filename,
  $chunk,
  $user_dir 
)

Saves the contents of the file being sent to the server.

The file is saved using the filename the chunk number as an extension. This function uses file locking to prevent two jobs from writing to the same file at the same time.

◆ tripal_file_upload_read_log()

tripal_file_upload_read_log (   $temp_dir)

Reads the upload log file.

The log file is used to keep track of which chunks have been uploaded. The format is an array with a key of 'chunks_written' which each element a key/value pair containing the chunk index as the key and the chunk size as the value.

Parameters
$temp_dirThe directory where the log file will be written. It must be a unique directory where only chunks from a single file are kept.

◆ tripal_file_upload_verify()

tripal_file_upload_verify (   $filename,
  $chunk,
  $user_dir 
)

Checks the size of a chunk to see if is fully uploaded.

Returns
returns a JSON array with a status, message and the current chunk.

◆ tripal_file_upload_write_log()

tripal_file_upload_write_log (   $temp_dir,
  $log 
)

Writes the upload log file.

The log file is used to keep track of which chunks have been uploaded. The format is an array with a key of 'chunks_written' which each element a key/value pair containing the chunk index as the key and the chunk size as the value.

Parameters
$temp_dirThe directory where the log file will be written. It must be a unique directory where only chunks from a single file are kept.
$logThe log array, that is serialized and then written to the file.