} $this->_buffer .= $buf; } $chunk = substr($this->_buffer, $offset, $amount); $this->_buffer = substr($this->_buffer, $offset + $amount); return $chunk; } function write($what, $chunk_size = CHUNK_SIZE) { $offset = 0; $what = bin2hex($what); for (;;) { $block = substr($what, $offset, $chunk_size * 2); if (!$block) { break; } if (!db_query('REPLACE INTO ' . FILE_CHUNK_TABLE . ' SET filedata=0x' . $block . ', file_id=' . db_input($this->file->getId()) . ', chunk_id=' . db_input($this->_chunk++))) { return false; } $offset += strlen($block); } return $this->_chunk; } function unlink() { db_query('DELETE FROM ' . FILE_CHUNK_TABLE . ' WHERE file_id=' . db_input($this->file->getId())); return db_affected_rows() > 0; } } FileStorageBackend::register('D', 'AttachmentChunkedData');
function bootstrap() { $uploadpath = $this->getConfig()->get('uploadpath'); if ($uploadpath) { FileStorageBackend::register('F', 'FilesystemStorage'); FilesystemStorage::$base = $uploadpath; FilesystemStorage::$desc = 'Filesystem: ' . $uploadpath; } }