Exemplo n.º 1
0
    /// <summary>
    /// 0 - NEW IMAGE NAME
    /// 1 - LOCATION WITH NAME
    /// </summary>
    /// <param name="newname"></param>
    /// <param name="containerName"></param>
    /// <param name="i"></param>
    /// <returns></returns>
    public string[] Save(string newname, string containerName, Image i)
    {
        string cleanImage = null;

        try
        {
            BlobStorageHandlerManager.BlobStorageHandler sh = new BlobStorageHandlerManager.BlobStorageHandler();
            Image       thisImage    = i;
            string      extension    = getMediaData(thisImage.RawFormat);
            string      newImageName = string.Empty;
            ImageFormat imageFormat  = getImageFormatFromExtension(extension);
            string      contenttype  = getContentType(extension);

            cleanImage   = newname + extension;
            newImageName = cleanImage;

            if (imageFormat != null)
            {
                sh.SaveFile(UtilsImage.ToStream(thisImage, imageFormat), newImageName, contenttype, containerName);
                location = newImageName;
                location = UtilsConfig.Get(enumConfigKeys.Storage_BlobUri) + containerName + location;

                return(new string[] { newImageName, location });
            }
        }
        catch (Exception ex)
        {
        }

        return(null);
    }
Exemplo n.º 2
0
 public bool DeleteImage(string location)
 {
     BlobStorageHandlerManager.BlobStorageHandler sh = new BlobStorageHandlerManager.BlobStorageHandler();
     location = location.Replace(UtilsConfig.Get(enumConfigKeys.Storage_BlobUri) + UtilsConfig.Get(enumConfigKeys.Storage_Container), "");
     sh.DeleteFile(location, UtilsConfig.Get(enumConfigKeys.Storage_Container));
     return(true);
 }