मैं सोच रहा था कि मैं अपने एपीआई का उपयोग कर रैकस्पेस के क्लाउडफाइल से फ़ाइल कैसे हटा सकता हूं?मैं अपने एपीआई के साथ रैकस्पेस के क्लाउडफाइल से फ़ाइल कैसे हटा सकता हूं?
मैं php का उपयोग कर रहा हूं।
देवन
मैं सोच रहा था कि मैं अपने एपीआई का उपयोग कर रैकस्पेस के क्लाउडफाइल से फ़ाइल कैसे हटा सकता हूं?मैं अपने एपीआई के साथ रैकस्पेस के क्लाउडफाइल से फ़ाइल कैसे हटा सकता हूं?
मैं php का उपयोग कर रहा हूं।
देवन
उपयोग CF_Container की delete_object विधि।
यहां मेरा कोड सी # है। बस एपीआई अनुमान लगाना PHP के लिए समान है।
UserCredentials userCredientials = new UserCredentials("xxxxxx", "99999999999999");
cloudConnection = new Connection(userCredientials);
cloudConnection.DeleteStorageItem(ContainerName, fileName);
सुनिश्चित करें कि आप कंटेनर सेट करें और किसी भी सुडो फ़ोल्डर को परिभाषित कर रहे हैं जिसे आप उपयोग कर रहे हैं।
$my_container = $this->conn->get_container($cf_container);
//delete file
$my_container->delete_object($cf_folder.$file_name);
मैं मैं यहाँ पोस्ट के बाद से वहाँ एक जवाब सही एक के रूप में चिह्नित नहीं है, हालांकि मैं सही एक के रूप में मैथ्यू Flaschen जवाब को स्वीकार करेंगे सोचा। यह सब कोड आप अपनी फ़ाइल
<?php
require '/path/to/php-cloudfiles/cloudfiles.php';
$username = 'my_username';
$api_key = 'my_api_key';
$full_object_name = 'this/is/the/full/file/name/in/the/container.png';
$auth = new CF_Authentication($username, $api_key);
$auth->ssl_use_cabundle();
$auth->authenticate();
if ($auth->authenticated())
{
$this->connection = new CF_Connection($auth);
// Get the container we want to use
$container = $this->connection->get_container($name);
$object = $container->delete_object($full_object_name);
echo 'object deleted';
}
else
{
throw new AuthenticationException("Authentication failed") ;
}
नोट कि "$ full_object_name" कंटेनर में फ़ाइल और साथ कोई प्रारंभिक '/' फ़ाइल नाम में "पथ" भी शामिल है को हटाने की आवश्यकता होगी। ऐसा इसलिए है क्योंकि कंटेनर एक छद्म-पदानुक्रमित फ़ोल्डरों/निर्देशिकाओं का उपयोग करते हैं और कंटेनर में फ़ाइल का नाम होने का अंत क्या पथ + फ़ाइल नाम है। अधिक जानकारी के लिए देखते हैं http://docs.rackspace.com/files/api/v1/cf-devguide/content/Pseudo-Hierarchical_Folders_Directories-d1e1580.html
वर्ग CF_Container से विधि DeleteObject कहा जाता है का उपयोग करें।
विधि CFOontainer के DeleteObject की विधि केवल एक स्ट्रिंग तर्क object_name की आवश्यकता है। यह तर्क हटाए जाने के लिए फ़ाइल नाम होना चाहिए।
bellow उदाहरण सी # कोड देखें: मत वर्ग से DeleteObject का उपयोग * CF_Client
string username = "your-username";
string apiKey = "your-api-key";
CF_Client client = new CF_Client();
UserCredentials creds = new UserCredentials(username, apiKey);
Connection conn = new CF_Connection(creds, client);
conn.Authenticate();
var containerObj = new CF_Container(conn, client, container);
string file = "filename-to-delete";
containerObj.DeleteObject(file);
नोट *