2011-12-14 13 views

答えて

0

にあなたがInMemoryFileとInMemoryDownloadableFileクラスを使用することができます

感謝。 例:

private class AttachmentFile : InMemoryDownloadableFile 
    { 
     public AttachmentFile(byte[] file, string filename, string contenttype) 
     { 
      OpenStream().Write(file, 0, file.Length); 
      this.FileName = filename; 
      this.ContentType = new MediaType(contenttype); 
     } 
    } 

    private class InlineFile : InMemoryFile 
    { 
     public InlineFile(byte[] file, string filename, string contenttype) 
     { 
      OpenStream().Write(file, 0, file.Length); 
      this.FileName = filename; 
      this.ContentType = new MediaType(contenttype); 
     } 
    } 

    [HttpOperation(HttpMethod.GET)] 
    public object Get(string filename) 
    { 

      bool inline = false; //server attachments inline or as download 
      try 
      { 
       inline = Convert.ToBoolean(Params["INLINE"]); 
      } 
      catch { } 

      string contenttype = set contentttype... 
      byte[] attachment = read file.... 

      if (inline) 
       return new InlineFile(attachment, filename, contenttype); 
      else return new AttachmentFile(attachment, filename, contenttype); 
     } 
     else return new OperationResult.Forbidden(); 
    } 
関連する問題