2014-01-09 56 views
0

我已經使用附件id獲取附件詳細信息,使用rest api執行並從其他api獲取文檔,但是如何讀取該附件並保存在物理文件夾中否關於它是zip文件pdf還是文檔的問題?如何從jira讀取附件並使用Rest Api保存

public Attachment GetAttachment(string attachmentId) 
    { 
     var request = new RestRequest() 
     { 
      Method = Method.GET, 
      Resource = ResourceUrls.AttachmentById(attachmentId), 
      RequestFormat = DataFormat.Json 
     }; 

     return Execute<Attachment>(request, HttpStatusCode.OK); 
    } 
public class Attachment 
{ 
    public string self { get; set; } 
    public string filename { get; set; } 
    public Author author { get; set; } 
    public string created { get; set; } 
    public int size { get; set; } 
    public string mimeType { get; set; } 
    public string content { get; set; } 
    public string thumbnail { get; set; } 
} 

但是如何閱讀附件?

回答

0

getContent()然後base64解碼返回的字符串,我相信。內容類型根據附件在上傳時的名稱(擴展名)設置,並可用於確定解碼的附件內容中的數據類型。

+0

如何獲取附件的內容樣本說明?內容屬性我得到的URL爲「JIRA /安全/附件/ 39532/1.doc」,如果我在瀏覽器中使用它提示保存該文件。 – cmj