CREATE TABLE IF NOT EXISTS `bx_posts_covers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`profile_id` int(10) unsigned NOT NULL,
`remote_id` varchar(128) NOT NULL,
`path` varchar(255) NOT NULL,
`file_name` varchar(255) NOT NULL,
`mime_type` varchar(128) NOT NULL,
`ext` varchar(32) NOT NULL,
`size` bigint(20) NOT NULL,
`added` int(11) NOT NULL,
`modified` int(11) NOT NULL,
`private` int(11) NOT NULL,
`dimensions` varchar(12) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `remote_id` (`remote_id`)
);
SET @sStorageEngine = (SELECT `value` FROM `sys_options` WHERE `name` = 'sys_storage_default');
INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `cache_control`, `levels`, `table_files`, `ext_mode`, `ext_allow`, `ext_deny`, `quota_size`, `current_size`, `quota_number`, `current_number`, `max_file_size`, `ts`) VALUES
('bx_posts_photos', @sStorageEngine, '', 360, 2592000, 3, 'bx_posts_photos', 'allow-deny', '{image}', '', 0, 0, 0, 0, 0, 0),
('bx_posts_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_posts_files', 'deny-allow', '', '{dangerous}', 0, 0, 0, 0, 0, 0);
'OBJECT_STORAGE' => 'bx_posts_covers',
'OBJECT_STORAGE_FILES' => 'bx_posts_files',
'OBJECT_STORAGE_PHOTOS' => 'bx_posts_photos',
'OBJECT_STORAGE_VIDEOS' => 'bx_posts_videos',
'OBJECT_STORAGE_SOUNDS' => 'bx_posts_sounds',
$CNF = &$this->_oConfig->CNF;
$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE_FILES']);
if (!$oStorage)
return false;
// the second argument is $isPrivate, and it defaults to true
$iFileId = $oStorage->storeFileFromForm($_FILES['file'], false, $iProfileId);
if (!$iFileId)
return $oStorage->getErrorString(); // or getErrorCode()
// the id is now saved on your content row, so the upload is no longer a ghost
$oStorage->afterUploadCleanup($iFileId, $iProfileId);
$sUrl = $oStorage->getFileUrlById($iFileId);
$aFile = $oStorage->getFile($iFileId); // files-table row, or false
DELETE FROM `sys_objects_storage` WHERE `object` LIKE 'bx_posts_%';
DELETE FROM `sys_storage_tokens` WHERE `object` LIKE 'bx_posts_%';