public function objectDelete($iObjectId)
    {
        $oDb = Factory::service('Database');

        try {

            $object = $this->getObject($iObjectId);
            if (empty($object)) {
                throw new CdnException('Not a valid object');
            }

            // --------------------------------------------------------------------------

            $aObjectData = [
                'id'               => $object->id,
                'bucket_id'        => $object->bucket->id,
                'filename'         => $object->file->name->disk,
                'filename_display' => $object->file->name->human,
                'mime'             => $object->file->mime,
                'filesize'         => $object->file->size->bytes,
                'img_width'        => $object->img_width,
                'img_height'       => $object->img_height,
                'img_orientation'  => $object->img_orientation,
                'is_animated'      => $object->is_animated,
                'serves'           => $object->serves,
                'downloads'        => $object->downloads,
                'thumbs'           => $object->thumbs,
                'scales'           => $object->scales,
                'driver'           => $object->driver,
                'created'          => $object->created,
                'created_by'       => $object->created_by,
                'modified'         => $object->modified,
                'modified_by'      => $object->modified_by,
            ];

            $oDb->set($aObjectData);
            $oDb->set('trashed', 'NOW()', false);

            if (isLoggedIn()) {
                $oDb->set('trashed_by', activeUser('id'));
            }

            //  Start transaction
            $oDb->trans_begin();

            //  Create trash object
            if (!$oDb->insert(NAILS_DB_PREFIX . 'cdn_object_trash')) {
                throw new CdnException('Failed to create the trash object.');
            }

            //  Remove original object
            $oDb->where('id', $object->id);
            if (!$oDb->delete(NAILS_DB_PREFIX . 'cdn_object')) {
                throw new CdnException('Failed to remove original object.');
            }

            $oDb->trans_commit();

            //  Clear caches
            $this->unsetCacheObject($object);

            return true;

        } catch (\Exception $e) {

            $oDb->trans_rollback();
            $this->setError($e->getMessage());

            return false;
        }
    }