Esempio n. 1
0
        public async Task <IActionResult> UploadFile(IFormFile file)
        {
            var path = await _fileUploader.UploadFileAsync(file);

            var processFileResult = _csvProcessor.ProcessFile(path);

            var processFileResultModel = _processFileResultMapper.Map(processFileResult);

            return(View(processFileResultModel));
        }
Esempio n. 2
0
        public async Task RunAsync()
        {
            string accessToken = string.Empty;

            while (string.IsNullOrWhiteSpace(accessToken))
            {
                Console.WriteLine($"Paste in fabric identity access token [ENTER for {Properties.Settings.Default.AccessToken}]");
                accessToken = NewReadLine();
                if (string.IsNullOrWhiteSpace(accessToken))
                {
                    accessToken = Properties.Settings.Default.AccessToken;
                }
            }

            Properties.Settings.Default.AccessToken = accessToken;

            string filePath = string.Empty;

            while (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
            {
                Console.WriteLine($"Enter Full Path to file [ENTER for {Properties.Settings.Default.FilePath}]");
                filePath = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(filePath))
                {
                    filePath = Properties.Settings.Default.FilePath;
                }
            }

            Properties.Settings.Default.FilePath = filePath;


            Console.WriteLine($"Enter resource id to use (ENTER for {Properties.Settings.Default.ResourceId})");
            var resourceIdText = Console.ReadLine();
            int resourceId     = string.IsNullOrEmpty(resourceIdText) ? Properties.Settings.Default.ResourceId : Convert.ToInt32(resourceIdText);

            Properties.Settings.Default.ResourceId = resourceId;

            Console.WriteLine($"Enter url to MDS v2 [ENTER for {Properties.Settings.Default.MdsV2Url}]");
            var uriString = Console.ReadLine();
            var mdsV2Url  = string.IsNullOrWhiteSpace(uriString) ? new Uri(Properties.Settings.Default.MdsV2Url) : new Uri(uriString);

            Properties.Settings.Default.MdsV2Url = mdsV2Url.ToString();

            var fileUploader = new FileUploader(new FileServiceAccessTokenRepository(accessToken), mdsV2Url);

            fileUploader.Navigating              += FileUploader_Navigating;
            fileUploader.Navigated               += FileUploader_Navigated;
            fileUploader.PartUploaded            += FileUploader_PartUploaded;
            fileUploader.FileUploadStarted       += FileUploader_FileUploadStarted;
            fileUploader.FileUploadCompleted     += FileUploader_FileUploadCompleted;
            fileUploader.UploadError             += FileUploader_UploadError;
            fileUploader.SessionCreated          += FileUploader_SessionCreated;
            fileUploader.FileChecked             += FileUploader_FileChecked;
            fileUploader.TransientError          += FileUploader_TransientError;
            fileUploader.AccessTokenRequested    += FileUploader_AccessTokenRequested;
            fileUploader.NewAccessTokenRequested += FileUploader_NewAccessTokenRequested;
            fileUploader.CalculatingHash         += FileUploader_CalculatingHash;
            fileUploader.Committing              += FileUploader_Committing;
            fileUploader.CheckingCommit          += FileUploader_CheckingCommit;

            Properties.Settings.Default.Save();

            using (CancellationTokenSource cts = new CancellationTokenSource())
            {
                // var utTempFolder = Path.GetTempPath();
                try
                {
                    await fileUploader.UploadFileAsync(resourceId, filePath, cts.Token);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
 /// <summary>
 /// Check <see cref="IAssetService"/> for more information
 /// </summary>
 /// <param name="query">Check <see cref="IAssetService"/> for more information</param>
 /// <returns>Check <see cref="IAssetService"/> for more information</returns>
 public async Task UploadFileAsync(UploadQuery query)
 {
     await _uploader.UploadFileAsync(query).ConfigureAwait(false);
 }
Esempio n. 4
0
 /// <summary>
 /// Check <see cref="IAssetService"/> for more information
 /// </summary>
 /// <param name="query">Check <see cref="IAssetService"/> for more information</param>
 /// <returns>Check <see cref="IAssetService"/> for more information</returns>
 public async Task <SaveMediaResponse> UploadFileAsync(UploadQuery query)
 {
     return(await _uploader.UploadFileAsync(query).ConfigureAwait(false));
 }