Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed JIRA attachments downloading issue. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions TicketImporter/JiraProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License
using System.IO;
using System.Linq;
using System.Net;
using RestSharp.Extensions;
using System.Text;
using TechTalk.JiraRestClient;
using TicketImporter.Interface;
using TrackProgress;
Expand Down Expand Up @@ -189,8 +189,8 @@ public void DownloadAttachments(Ticket ticket, string downloadFolder)
foreach (var attachment in ticket.Attachments)
{
onDetailedProcessing("Downloading " + attachment.FileName);
var sourceUri = string.Format("{0}?&os_username={1}&os_password={2}",
attachment.Source, userName, password);
var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(userName + ":" + password));
var sourceUri = attachment.Source;
string name = Path.GetFileNameWithoutExtension(attachment.FileName),
extension = Path.GetExtension(attachment.FileName),
downloadedName = attachment.FileName;
Expand All @@ -207,6 +207,7 @@ public void DownloadAttachments(Ticket ticket, string downloadFolder)
try
{
var downloadTo = Path.Combine(downloadFolder, downloadedName);
webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", credentials);
webClient.DownloadFile(new Uri(sourceUri), downloadTo);
attachment.Source = downloadTo;
attachment.FileName = downloadedName;
Expand Down