コード例 #1
0
        public async Task <Stream> GetPackageContentStreamOrNullAsync(
            string id,
            NuGetVersion version,
            CancellationToken cancellationToken = default)
        {
            // Allow read-through caching if it is configured.
            await _mirror.MirrorAsync(id, version, cancellationToken);

            if (!await _packages.AddDownloadAsync(id, version))
            {
                return(null);
            }

            return(await _storage.GetPackageStreamAsync(id, version, cancellationToken));
        }
コード例 #2
0
ファイル: PackageController.cs プロジェクト: nimrodolev/BaGet
        public async Task <IActionResult> DownloadPackage(string id, string version, CancellationToken cancellationToken)
        {
            if (!NuGetVersion.TryParse(version, out var nugetVersion))
            {
                return(NotFound());
            }

            // Allow read-through caching if it is configured.
            await _mirror.MirrorAsync(id, nugetVersion, cancellationToken);

            if (!await _packages.AddDownloadAsync(id, nugetVersion))
            {
                return(NotFound());
            }

            var packageStream = await _storage.GetPackageStreamAsync(id, nugetVersion, cancellationToken);

            return(File(packageStream, "application/octet-stream"));
        }
コード例 #3
0
        public async Task <IActionResult> DownloadPackage(string id, string version)
        {
            if (!NuGetVersion.TryParse(version, out var nugetVersion))
            {
                return(NotFound());
            }

            if (!await _packages.ExistsAsync(id, nugetVersion))
            {
                return(NotFound());
            }

            await _packages.AddDownloadAsync(id, nugetVersion);

            var identity      = new PackageIdentity(id, nugetVersion);
            var packageStream = await _storage.GetPackageStreamAsync(identity);

            return(File(packageStream, "application/octet-stream"));
        }
コード例 #4
0
 public Task AddDownloadAsync(string id, NuGetVersion version) => _localPackages.AddDownloadAsync(id, version);