/** * Delete a blob from specified container * * @param string $containerName Name of the parent container * * @param string $blobName Name of the blob to be deleted * * @return void */ function deleteBlob($containerName, $blobName) { try { if (WindowsAzureStorageUtil::blobExists($containerName, $blobName)) { $_SERVER['REQUEST_URI'] = remove_query_arg(array('delete_blob', 'filename', 'selected_container'), $_SERVER['REQUEST_URI']); WindowsAzureStorageUtil::deleteBlob($containerName, $blobName); } } catch (Exception $e) { /* translators: 1: blob (file) name, 2: container name, 3: error message */ $message = sprintf(__('Error in deleting blob %1$s from container %2$s: %3$s', 'windows-azure-storage'), $blobName, $containerName, $e->getMessage()); echo '<p class="warning">' . esc_html($message) . '</p>'; } }
/** * Hook for handling deleting media files from standard WordpRess dialog * * @param string $postID post id * * @return void */ function windows_azure_storage_delete_attachment($postID) { if (is_numeric($postID)) { $mediaInfo = get_post_meta($postID, 'windows_azure_storage_info', true); if (!empty($mediaInfo)) { // Delete media file from blob storage $containerName = $mediaInfo['container']; $blobName = $mediaInfo['blob']; WindowsAzureStorageUtil::deleteBlob($containerName, $blobName); // Delete associated thumbnails from blob storage (if any) $thumbnails = $mediaInfo['thumbnails']; if (!empty($thumbnails)) { foreach ($thumbnails as $thumbnail_blob) { WindowsAzureStorageUtil::deleteBlob($containerName, $thumbnail_blob); } } } } }
/** * Delete a blob from specified container * * @param string $containerName Name of the parent container * * @param string $blobName Name of the blob to be deleted * * @return void */ function deleteBlob($containerName, $blobName) { try { if (WindowsAzureStorageUtil::blobExists($containerName, $blobName)) { remove_query_arg('deleteBlob', $_SERVER['REQUEST_URI']); WindowsAzureStorageUtil::deleteBlob($containerName, $blobName); } } catch (Exception $e) { echo '<p style="margin: 10px; color: red;">' . 'Error in deleting blob $blobName from container $containerName : ' . $e->getMessage() . "</p><br/>"; } }