示例#1
0
        /// <summary>
        /// Create a cloud storage account using an ARM storage management client
        /// </summary>
        /// <param name="provider">The adapter to ARM storage services.</param>
        /// <param name="resourceGroupName">The resource group containing the storage account.</param>
        /// <param name="accountName">The name of the storage account.</param>
        /// <returns>A CloudStorageAccount that can be used by windows azure storage library to manipulate objects in the storage account.</returns>
        public static CloudStorageAccount GenerateCloudStorageAccount(IStorageServiceProvider provider,
                                                                      string resourceGroupName, string accountName)
        {
            if (!TestMockSupport.RunningMocked)
            {
                var service = provider.GetStorageService(accountName, resourceGroupName);


                return(new CloudStorageAccount(
                           new StorageCredentials(service.Name, service.AuthenticationKeys.First()),
                           service.BlobEndpoint,
                           service.QueueEndpoint,
                           service.TableEndpoint,
                           service.FileEndpoint));
            }
            else
            {
                return(new CloudStorageAccount(
                           new StorageCredentials(accountName,
                                                  Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))),
                           new Uri(string.Format("https://{0}.blob.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.queue.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.table.core.windows.net", accountName)),
                           new Uri(string.Format("https://{0}.file.core.windows.net", accountName))));
            }
        }
        /// <summary>
        /// Create a cloud storage account using an ARM storage management client
        /// </summary>
        /// <param name="provider">The adapter to ARM storage services.</param>
        /// <param name="resourceGroupName">The resource group containing the storage account.</param>
        /// <param name="accountName">The name of the storage account.</param>
        /// <returns>A CloudStorageAccount that can be used by windows azure storage library to manipulate objects in the storage account.</returns>
        public static CloudStorageAccount GenerateCloudStorageAccount(IStorageServiceProvider provider,
            string resourceGroupName, string accountName)
        {
            if (!TestMockSupport.RunningMocked)
            {
                var service = provider.GetStorageService(accountName, resourceGroupName);


                return new CloudStorageAccount(
                    new StorageCredentials(service.Name, service.AuthenticationKeys.First()),
                    service.BlobEndpoint,
                    service.QueueEndpoint,
                    service.TableEndpoint,
                    service.FileEndpoint);
            }
            else
            {
                return new CloudStorageAccount(
                    new StorageCredentials(accountName,
                        Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))),
                    new Uri(string.Format("https://{0}.blob.core.windows.net", accountName)),
                    new Uri(string.Format("https://{0}.queue.core.windows.net", accountName)),
                    new Uri(string.Format("https://{0}.table.core.windows.net", accountName)),
                    new Uri(string.Format("https://{0}.file.core.windows.net", accountName)));
            }
        }
        public DocumentsController(IDocumentService documentServce)
        {
            _documentService = documentServce;

            //ESTO DEBE SER DINAMICO, POR UNITY O POR WEB.CONFIG
            storageService      = new AzureBlobService();
            containerBucketName = System.Configuration.ConfigurationManager.AppSettings["ContainerBucketName"];
        }
示例#4
0
        /// <summary>
        /// Get a CloudStorageAccount client for the given storage service using the given storage service provider
        /// </summary>
        /// <param name="provider">The storage service provider to retrieve storage service details</param>
        /// <param name="accountName">The storage accoutn name</param>
        /// <returns>A CloudStorageAccount client for storage data plane tasks</returns>
        public static CloudStorageAccount GetCloudStorageAccount(this IStorageServiceProvider provider, string accountName, string resourceGroupName = null)
        {
#if DEBUG
            if (TestMockSupport.RunningMocked)
            {
                return(new CloudStorageAccount(new StorageCredentials(accountName,
                                                                      Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))), true));
            }
#endif
            return(provider.GetStorageService(accountName, resourceGroupName).GetCloudStorageAccount());
        }
示例#5
0
 public FilesController(ILogger <FilesController> logger,
                        IHttpContextAccessor contextAccessor,
                        IStorageServiceProvider storageServiceProvider,
                        IOptions <HiarcSettings> hiarcSettings,
                        IHiarcDatabase hiarcDatabase)
 {
     _logger                 = logger;
     _contextAccessor        = contextAccessor;
     _storageServiceProvider = storageServiceProvider;
     _hiarcSettings          = hiarcSettings.Value;
     _hiarcDatabase          = hiarcDatabase;
 }
示例#6
0
 /// <summary>
 /// Create storage credentials for the given account
 /// </summary>
 /// <param name="provider">The storage provider for ARM storage services.</param>
 /// <param name="resourceGroupName">The resource group containing the storage account.</param>
 /// <param name="accountName">The storage account name.</param>
 /// <returns>Storage credentials for the given account.</returns>
 public static StorageCredentials GenerateStorageCredentials(IStorageServiceProvider provider,
                                                             string resourceGroupName, string accountName)
 {
     if (!TestMockSupport.RunningMocked)
     {
         var service = provider.GetStorageService(accountName, resourceGroupName);
         return(new StorageCredentials(accountName, service.AuthenticationKeys.First()));
     }
     else
     {
         return(new StorageCredentials(accountName,
                                       Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()))));
     }
 }
        public ActionResult Import(UserImportViewModel model)
        {
            IStorageServiceProvider storageService = null;

            if (model.StorageProvider == "azure")
            {
                storageService = new AzureBlobService();
            }
            if (model.StorageProvider == "aws")
            {
                storageService = new AWSBlobService();
            }
            if (storageService != null)
            {
                string myBucketName = System.Configuration.ConfigurationManager.AppSettings["ContainerBucketName"];
                Tuple <string, string> resultUpload = storageService.UploadPublicFile(model.ImportedFile.InputStream, model.ImportedFile.FileName, myBucketName);
                model.FinalUrl = resultUpload.Item1;
            }

            return(View("Index", model));
        }
        public ActionResult Import(MonitorViewModel model)
        {
            IStorageServiceProvider storageService = null;

            if (model.StorageProvider == "azure")
            {
                storageService = new AzureBlobService();
            }
            if (model.StorageProvider == "aws")
            {
                storageService = new AWSBlobService();
            }
            if (storageService != null)
            {
                string myBucketName = System.Configuration.ConfigurationManager.AppSettings["ContainerBucketName"];
                Tuple <string, string> resultUpload = storageService.UploadPublicFile(model.ImportedFile.InputStream, model.ImportedFile.FileName, myBucketName);
                model.FinalUrl = resultUpload.Item1;
            }

            HttpResponseMessage  response = ProcessImageUrl(model.FinalUrl);
            IEnumerable <string> values;

            if (response.Headers.TryGetValues("Operation-Location", out values))
            {
                model.FinalUrl = values.First();
            }

            Thread.Sleep(3000);

            model.Content = ProcessResultUrl(model.FinalUrl);

            ResultMonitor result = JsonUtil.ConvertToObject <ResultMonitor>(model.Content);

            model.ResultMonitor = result;

            return(View("Index", model));
        }
示例#9
0
 public BlobCsvFunction(ICsvMovieConverter csvMovieConverter, IStorageServiceProvider storageServiceProvider, ServiceBlobResolver serviceAccessor)
 {
     _csvMovieConverter         = csvMovieConverter;
     _queue                     = storageServiceProvider.GetQueueTable("movies");
     _csvSplittedCrudRepository = serviceAccessor("CsvSplitted");
 }
 public CsvMoviesCrudRepository(IStorageServiceProvider storageTableProvider)
 {
     _blobContainerClient = storageTableProvider.GetContainerClient("csvmovies");
     _blobContainer       = storageTableProvider.GetBlobContainer("csvmovies");
 }
示例#11
0
        /// <summary>
        /// Get the current storage account.
        /// </summary>
        /// <param name="context">The current Azure context.</param>
        /// <returns>The current storage account, or null, if no current storage account is set.</returns>
        public static CloudStorageAccount GetCurrentStorageAccount(this IAzureContext context, IStorageServiceProvider provider)
        {
            if (context != null)
            {
                var storageConnectionString = context.GetCurrentStorageAccountConnectionString();
                try
                {
                    return
                        (CloudStorageAccount.Parse(storageConnectionString));
                }
                catch
                {
                    var service = provider.GetStorageService(storageConnectionString, null);
                    return(service.GetCloudStorageAccount());
                }
            }

            return(null);
        }
示例#12
0
 public CsvSplittedCrudRepository(IStorageServiceProvider storageTableProvider)
 {
     _blobContainerClient = storageTableProvider.GetContainerClient("csvsplitted");
     _blobContainer       = storageTableProvider.GetBlobContainer("csvsplitted");
 }
示例#13
0
 public HomeController(IStorageServiceProvider provider)
 {
     var storage = provider.GetStorageService <Domain.User.UserInfo>();
 }
 public MovieCrudRepository(IStorageServiceProvider storageTableProvider)
 {
     _table = storageTableProvider.GetStorageTable("movies");
 }
 public MovieImageCrudRepository(IStorageServiceProvider storageTableProvider)
 {
     _blobContainerClient = storageTableProvider.GetContainerClient("movieimages");
     _blobContainer       = storageTableProvider.GetBlobContainer("movieimages");
 }
 /// <summary>
 /// Create storage credentials for the given account
 /// </summary>
 /// <param name="provider">The storage provider for ARM storage services.</param>
 /// <param name="resourceGroupName">The resource group containing the storage account.</param>
 /// <param name="accountName">The storage account name.</param>
 /// <returns>Storage credentials for the given account.</returns>
 public static StorageCredentials GenerateStorageCredentials(IStorageServiceProvider provider,
     string resourceGroupName, string accountName)
 {
     if (!TestMockSupport.RunningMocked)
     {
         var service = provider.GetStorageService(accountName, resourceGroupName);
         return new StorageCredentials(accountName, service.AuthenticationKeys.First());
     }
     else
     {
         return new StorageCredentials(accountName,
             Convert.ToBase64String(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())));
     }
 }
示例#17
0
        /// <summary>
        /// Get a CloudStorageAccount client for the current storage service using the given storage service provider
        /// </summary>
        /// <param name="context">The current Azure context.</param>
        /// <param name="provider">The storage service provider to retrieve storage service details</param>
        /// <returns>A CloudStorageAccount client for storage data plane tasks</returns>
        public static CloudStorageAccount GetCloudStorageAccount(this IAzureContext context, IStorageServiceProvider provider)
        {
            CloudStorageAccount account;
            var storageConnectionString = context.GetCurrentStorageAccountConnectionString();

            if (!CloudStorageAccount.TryParse(storageConnectionString, out account))
            {
                if (null == provider)
                {
                    throw new ArgumentNullException("provider");
                }

                account = provider.GetCloudStorageAccount(storageConnectionString);
            }

            return(account);
        }
示例#18
0
 public ApiKeyCrudRepository(IStorageServiceProvider storageTableProvider)
 {
     _table = storageTableProvider.GetStorageTable("apikey");
 }