function deleteObject(FileSync $fileSync)
{
    $object = kFileSyncUtils::retrieveObjectForFileSync($fileSync);
    $key = $object->getSyncKey($fileSync->getObjectSubType());
    if ($key->version != $fileSync->getVersion()) {
        return;
    }
    switch ($fileSync->getObjectType()) {
        case FileSyncObjectType::UICONF:
            $object->setStatus(uiConf::UI_CONF_STATUS_DELETED);
            $object->save();
            break;
        case FileSyncObjectType::ENTRY:
            myEntryUtils::deleteEntry($object);
            try {
                $wrapper = objectWrapperBase::getWrapperClass($object);
                $wrapper->removeFromCache("entry", $object->getId());
            } catch (Exception $e) {
                KalturaLog::err($e);
            }
            break;
        case FileSyncObjectType::ASSET:
            $object->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
            $object->setDeletedAt(time());
            $object->save();
            break;
        case FileSyncObjectType::METADATA:
            $object->setStatus(Metadata::STATUS_DELETED);
            $object->save();
            break;
        default:
            return;
    }
    if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_LINK) {
        return;
    }
    $criteria = new Criteria();
    $criteria->add(FileSyncPeer::DC, $fileSync->getDc());
    $criteria->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_LINK);
    $criteria->add(FileSyncPeer::LINKED_ID, $fileSync->getId());
    $links = FileSyncPeer::doSelect($criteria);
    foreach ($links as $link) {
        deleteObject($link);
    }
}
function deleteExistObject($client, $s3bucket, $key)
{
    if (doesObjectExists($client, $s3bucket, $key)) {
        deleteObject($client, $s3bucket, $key);
    }
}
    $result = DBend($result);
    show_messages($result, _('Host deleted'), _('Cannot delete host'));
    if ($result) {
        unset($_REQUEST['form'], $_REQUEST['hostid']);
    }
    unset($_REQUEST['delete']);
    clearCookies($result);
} elseif ($_REQUEST['go'] == 'delete') {
    $hostIds = get_request('hosts', array());
    ###################################################################################################
    # mass delete racktables object
    require_once 'racktablesapi.php';
    foreach ($hostIds as $hostid) {
        $host = API::Host()->get(array('hostids' => $hostid, 'editable' => true, 'output' => API_OUTPUT_EXTEND));
        $host = reset($host);
        $response = deleteObject($host['host']);
        if (isset($response['error'])) {
            show_messages(false, '', 'Deleting racktables object is failed. Error message:' . $response['error']);
        }
    }
    ###################################################################################################
    DBstart();
    $goResult = API::Host()->delete($hostIds);
    $goResult = DBend($goResult);
    show_messages($goResult, _('Host deleted'), _('Cannot delete host'));
    clearCookies($goResult);
} elseif (str_in_array(getRequest('go'), array('activate', 'disable'))) {
    $enable = getRequest('go') == 'activate';
    $status = $enable ? TRIGGER_STATUS_ENABLED : TRIGGER_STATUS_DISABLED;
    $hosts = getRequest('hosts', array());
    $actHosts = API::Host()->get(array('hostids' => $hosts, 'editable' => true, 'templated_hosts' => true, 'output' => array('hostid', 'name')));
Exemple #4
0
 function wp_delete_file($file)
 {
     return $file;
     if (!$this->options) {
         $this->options = get_option('tantan_wordpress_s3');
     }
     if (!$this->options['wp-uploads'] || !$this->options['bucket'] || !$this->options['secret']) {
         return $file;
     }
     if (is_array($this->meta)) {
         require_once dirname(__FILE__) . '/lib.s3.php';
         $this->s3 = new TanTanS3($this->options['key'], $this->options['secret']);
         $this->s3->setOptions($this->options);
         if (deleteObject($this->meta['bucket'], $this->meta['key'])) {
         }
         $accessDomain = $this->options['cloudfront'] != '' ? $this->options['cloudfront'] : ($this->options['virtual-host'] ? $this->meta['bucket'] : $this->meta['bucket'] . '.s3.amazonaws.com');
         return $file;
         //return 'http://'.$accessDomain.'/'.$amazon['key'];
     }
     return $file;
 }
Exemple #5
0
    Common::println($object);
}
sleep(2);
unlink("c.file.localcopy");
//******************************* 完整用法参考下面函数 ****************************************************
listObjects($ossClient, $bucket);
listAllObjects($ossClient, $bucket);
createObjectDir($ossClient, $bucket);
putObject($ossClient, $bucket);
uploadFile($ossClient, $bucket);
getObject($ossClient, $bucket);
getObjectToLocalFile($ossClient, $bucket);
copyObject($ossClient, $bucket);
modifyMetaForObject($ossClient, $bucket);
getObjectMeta($ossClient, $bucket);
deleteObject($ossClient, $bucket);
deleteObjects($ossClient, $bucket);
doesObjectExist($ossClient, $bucket);
/**
 * 创建虚拟目录
 *
 * @param OssClient $ossClient OssClient实例
 * @param string $bucket 存储空间名称
 * @return null
 */
function createObjectDir($ossClient, $bucket)
{
    try {
        $ossClient->createObjectDir($bucket, "dir");
    } catch (OssException $e) {
        printf(__FUNCTION__ . ": FAILED\n");
Exemple #6
0
                    echo $sufficientValuesWereNotSupplied;
                }
            } else {
                if ($action == "update") {
                    $object = $data->{'object'};
                    $values = $data->{'values'};
                    $where = $data->{'where'};
                    if ($object && $values && $where) {
                        connectToDB();
                        updateObject($userId, $object, $values, $where);
                    } else {
                        echo $sufficientValuesWereNotSupplied;
                    }
                } else {
                    if ($action == "delete") {
                        $object = $data->{'object'};
                        $guid = $data->{'guid'};
                        if ($object && $guid) {
                            connectToDB();
                            deleteObject($object, $guid);
                        } else {
                            echo $sufficientValuesWereNotSupplied;
                        }
                    }
                }
            }
        }
    }
} else {
    print_r(errorParsingJSON());
}
Exemple #7
0
function deleteUser($user)
{
    global $sel_db;
    $user_name = $user;
    $object_id = getObjectIdbyName($sel_db, $user_name);
    if ($id != 'void') {
        $father_id = 1;
        deleteObject($sel_db, $object_id, $father_id);
    } else {
        vikingError("User name does not exists ({$user_name})");
    }
}
function verifyFileInS3($includeThumbnail)
{
    global $expectedMaxSize;
    $bucket = $_POST["bucket"];
    $key = $_POST["key"];
    // If utilizing CORS, we return a 200 response with the error message in the body
    // to ensure Fine Uploader can parse the error message in IE9 and IE8,
    // since XDomainRequest is used on those browsers for CORS requests.  XDomainRequest
    // does not allow access to the response body for non-success responses.
    if (getObjectSize($bucket, $key) > $expectedMaxSize) {
        // You can safely uncomment this next line if you are not depending on CORS
        //header("HTTP/1.0 500 Internal Server Error");
        deleteObject();
        echo json_encode(array("error" => "File is too big!"));
    } else {
        $link = getTempLink($bucket, $key);
        $response = array("tempLink" => $link);
        if ($includeThumbnail) {
            $response["thumbnailUrl"] = $link;
        }
        echo json_encode($response);
    }
}
Exemple #9
0
    $result = $client->putObject(array('Bucket' => $bucket, 'Key' => $key, 'Content' => $content));
    echo 'Put object etag: ' . $result->getETag();
}
// Sample of put object from resource
function putResourceObject(OSSClient $client, $bucket, $key, $content, $size)
{
    $result = $client->putObject(array('Bucket' => $bucket, 'Key' => $key, 'Content' => $content, 'ContentLength' => $size));
    echo 'Put object etag: ' . $result->getETag();
}
// Sample of get object
function getObject(OSSClient $client, $bucket, $key)
{
    $object = $client->getObject(array('Bucket' => $bucket, 'Key' => $key));
    echo "Object: " . $object->getKey() . "\n";
    echo (string) $object;
}
// Sample of delete object
function deleteObject(OSSClient $client, $bucket, $key)
{
    $client->deleteObject(array('Bucket' => $bucket, 'Key' => $key));
}
$keyId = 'your-access-key-id';
$keySecret = 'your-access-key-secret';
$client = createClient($keyId, $keySecret);
$bucket = 'your-bucket-name';
$key = 'your-object-key';
putStringObject($client, $bucket, $key, '123');
putStringObject($client, $bucket, $key, fopen('/path/to/file.txt', 'r'), filesize('/path/to/file.txt'));
getObject($client, $bucket, $key);
deleteObject($client, $bucket, $key);
function verifyFileInS3($includeThumbnail)
{
    global $expectedMaxSize;
    $bucket = $_REQUEST["bucket"];
    $key = $_REQUEST["key"];
    // If utilizing CORS, we return a 200 response with the error message in the body
    // to ensure Fine Uploader can parse the error message in IE9 and IE8,
    // since XDomainRequest is used on those browsers for CORS requests.  XDomainRequest
    // does not allow access to the response body for non-success responses.
    if (isset($expectedMaxSize) && getObjectSize($bucket, $key) > $expectedMaxSize) {
        // You can safely uncomment this next line if you are not depending on CORS
        header("HTTP/1.0 500 Internal Server Error");
        deleteObject();
        echo json_encode(array("error" => "File is too big!", "preventRetry" => true));
    } else {
        $link = getTempLink($bucket, $key);
        $metadata = getMetaData($bucket, $key);
        $size = getObjectSize($bucket, $key);
        $lastmodified = getObjectLastModified($bucket, $key);
        $response = array("link" => $link, "metadata" => $metadata, "key" => $key, "size" => $size, "lastmodified" => date('Y-m-d H:i:s', strtotime($lastmodified)));
        if ($includeThumbnail) {
            $response["thumbnailUrl"] = $link;
        }
        echo json_encode($response);
    }
}
Exemple #11
0
         echo "Text: {$tok}<br>";
         setObjectText($sel_db, $object_id, $tok);
         $tok = strtok(",;:");
     }
 }
 if ($post_action == 'post_rename_object') {
     $object_name = $_POST['a3_object_name'];
     if ($sel_db && $sel_object > 1 && $object_name) {
         renameNode($sel_db, $sel_object, $object_name);
         $a3pr[$sys_id]['a3_name'] = $object_name;
     }
 }
 if ($post_action == 'post_delete_object') {
     if ($sel_db && $sel_object > 1) {
         $father = $par['p2'];
         deleteObject($sel_db, $sel_object, $father);
         $a3pr[$sys_id]['a3_index2'] = '';
         $a3pr[$sys_id]['a3_from'] = '';
         $a3pr[$sys_id]['a3_from_father'] = '';
         $a3pr[$sys_id]['a3_object'] = 1;
     }
 }
 if ($post_action == 'post_create_db') {
     $sel_db = $_POST['a3_db'];
     $sel_db = str_replace(" ", "-", $sel_db);
     $a3pr[$sys_id]['a3_db'] = $sel_db;
     if ($sel_db) {
         createDb($sel_db, 3);
         //$sel_object = 1;
         $a3pr[$sys_id]['a3_object'] = 1;
     } else {