Exemplo n.º 1
0
        public async Task <ActionResult <ProblemDetails> > StoreUrl([Required] Uri url, string userAgent = null, bool?overwriteExisting = null, CancellationToken ct = default(CancellationToken))
        {
            try {
                var overwrite = overwriteExisting ?? true;
                var proceed   = overwrite || !await _storageService.FileExistsAsync(url, ct);

                if (proceed)
                {
                    var file = await _downloadService.DownloadUrlAsync(url, userAgent, ct);

                    await _storageService.UploadFileAsync(file, ct);
                }
                return(Sucess());
            }
            catch (Exception e) {
                return(Exception(e));
            }
        }