public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
}
*/
require_once realpath(dirname(__FILE__)) . '/../../require.php';
require_once PLUGIN_UPLOAD_REALDIR . 'WindowsAzureBlob/define.php';
$file_path = '';
if (isset($_REQUEST['file_path'])) {
    $file_path = $_REQUEST['file_path'];
} else {
    sendNotfound();
    exit(1);
}
if (strpos($file_path, IMAGE_SAVE_URLPATH) === false) {
    sendNotfound();
    exit(1);
}
require_once PLUGIN_UPLOAD_REALDIR . AZURE_BLOB_PLUGIN_NAME . '/class/helper/SC_Helper_AzureBlob.php';
$objBlob = SC_Helper_AzureBlob::getInstance();
$objFile = new BlobFile();
$objFile->file_name = str_replace(IMAGE_SAVE_URLPATH, '', $file_path);
$objFile->real_filepath = IMAGE_SAVE_REALDIR . $objFile->file_name;
$objBlob->copyToBlob($objFile);
if ($_REQUEST['type'] == 'blob') {
    echo ENDPOINT_PROTOCOL . '://' . AZURE_BLOB_ACCOUNT_NAME . '.blob.core.windows.net/' . $objBlob->containerName . '/save_image/' . $objFile->file_name;
} else {
    echo $file_path;
}
function sendNotfound()
{
    header("HTTP/1.1 404 File not found");
    exit(1);
}