public async Task <bool> UploadProjectPackageAsync(string projectName, string version, Stream zipArchiveStream) { var projectId = await _context.DocumentationProjects .Where(p => p.Name == projectName) .Select(p => p.Id) .FirstAsync(); // Try to read as zip file try { using (var transaction = await _context.Database.BeginTransactionAsync()) { var newVersion = new DocumentationProjectVersion { ProjectName = projectName, Version = version }; _context.DocumentationProjectVersions.Add(newVersion); await _context.SaveChangesAsync(); var packagePath = GetPackagePath(projectId, newVersion.FileId); var repoResult = await _fileManager.SaveFileAsync(AppConstants.PROJECTS_CONTAINER, packagePath, zipArchiveStream); if (repoResult.IsSuccess) { transaction.Commit(); return(true); } return(false); } } catch (InvalidDataException) { // Could not read the file as zip return(false); } catch { return(false); } }
public async Task <bool> UploadProjectPackageAsync(string projectName, string version, Stream zipArchiveStream) { var projectId = await _context.DocumentationProjects .Where(p => p.Name == projectName) .Select(p => p.Id) .FirstAsync(); // Try to read as zip file try { using (var transaction = await _context.Database.BeginTransactionAsync()) { var newVersion = new DocumentationProjectVersion { ProjectName = projectName, Version = version }; _context.DocumentationProjectVersions.Add(newVersion); await _context.SaveChangesAsync(); await SavedZipFileContentsToBlobStorage(projectId, newVersion.FileId, zipArchiveStream, _fileManager); transaction.Commit(); return(true); } } catch (InvalidDataException) { // Could not read the file as zip return(false); } catch { return(false); } }