BlobUtil
class BlobUtil
Constants
BAD_FILE_SUFFIXES |
|
Methods
Check to see if the $_POST is completely broken in file upload Sometimes, if the maxUpload_SIZE is exceeded, it deletes all of $_POST and we lose our session.
Check to see if the $_POST is completely broken in file upload Sometimes, if the maxUpload_SIZE is exceeded, it deletes all of $_POST
No description
No description
No description
No description
Returns true if this is a good upload, an error string if not
No description
Make sure the contents of this file are a PNG or JPEG
No description
No description
uploadToBlob - returns blob_id or false
isTestKey - Indicate if this is a key that is supposed to stay in blob_file
Legacy code - returns array [id, sha256]
Set the backref for a file entry
Read a file off local disk and put it into a blob
No description
Delete a blob based on its id
No description
No description
No description
No description
Check and migrate a blob from an old place to the right new place
Check and migrate a blob from blob_file to blob_blob
Check and migrate a blob to its corresponding file
Details
at line 15
static
emptyPostSessionLost()
Check to see if the $_POST is completely broken in file upload Sometimes, if the maxUpload_SIZE is exceeded, it deletes all of $_POST and we lose our session.
at line 24
static
emptyPost()
Check to see if the $_POST is completely broken in file upload Sometimes, if the maxUpload_SIZE is exceeded, it deletes all of $_POST
at line 32
static
uploadTooLarge($filename)
at line 37
static
getFolderName()
at line 50
static
fixFileName($name)
at line 65
static
safeFileSuffix($filename)
at line 74
static
validateUpload($FILE_DESCRIPTOR, $SAFETY_CHECK = true)
Returns true if this is a good upload, an error string if not
at line 95
static
checkFileSafety($FILE_DESCRIPTOR, $CONTENT_TYPES = array("image/png", "image/jpeg"))
at line 112
static
isPngOrJpeg($FILE_DESCRIPTOR)
Make sure the contents of this file are a PNG or JPEG
at line 123
static
getBlobFolder($sha_256, $blob_root = false)
at line 140
static
mkdirSha256($sha_256, $blob_root = false)
at line 172
static
uploadToBlob($FILE_DESCRIPTOR, $SAFETY_CHECK = true, $backref = null)
uploadToBlob - returns blob_id or false
Returns false for any number of failures, for better detail, use validateUpload() before calling this to do the actual upload.
at line 182
static
isTestKey($key)
isTestKey - Indicate if this is a key that is supposed to stay in blob_file
at line 206
static
uploadFileToBlob($FILE_DESCRIPTOR, $SAFETY_CHECK = true, $backref = null)
Legacy code - returns array [id, sha256]
Returns false for any number of failures, for better detail, use validateUpload() before calling this to do the actual upload.
at line 319
static
setBackref($file_id, $backref)
Set the backref for a file entry
This is a soft foreign key in the frorm of:
table:column:value peer_submit::submit_id::2
This is uses when we want to link a blob to a record at an even finer level than context_id and link_id which is done by default.
When an application is doing a two-phase commit where it is uploading the file and then creating the record in the table that references the file (i.e. peer_submit in the above example), it can set the back ref to have a value of -1 to indicate that the file is as yet unlinked
peer_submit::submit_id::-1
and then once the peer_submit record is committed call this routine to point to the real record in the table.
at line 337
static
uploadPathToBlob($filename, $content_type, $backref = null)
Read a file off local disk and put it into a blob
at line 418
static
uploadFileToString($FILE_DESCRIPTOR)
at line 446
static
deleteBlob($file_id, $admin_bypass = false)
Delete a blob based on its id
This cleans up files from the file table and if there are no more references to the file, eliminates the blob. This can only delete blobs in the current CONTEXT - but ultimately it is up to the calling code to decide who (i.e. an instructor) is allowed to delete a file.
at line 514
static
getAccessUrlForBlob($blob_id, $serv_file = false)
at line 523
static
maxUpload()
at line 534
static
maxUploadBytes()
at line 552
static
return_bytes($val)
at line 590
static mixed
migrate($file_id, $test_key = false)
Check and migrate a blob from an old place to the right new place
at line 612
static mixed
blob2blob($file_id)
Check and migrate a blob from blob_file to blob_blob
at line 696
static mixed
blob2file($file_id)
Check and migrate a blob to its corresponding file