예제 #1
0
 /// <summary>
 /// renders the binary embedded ressource.
 /// </summary>
 /// <param name="streamPath">an embedded dot separated path to the ressource. For example:
 /// ~/Ressource/EmbeddedBinaryRessource?streamPath=Plupload.Net.Scripts.plupload.flash.swf</param>
 /// <param name="contentType">a type of the content</param>
 /// <returns>file content result</returns>
 public FileContentResult EmbeddedBinaryRessource(string streamPath, string contentType = "application/octet-stream")
 {
     byte[] buffer = new byte[16 * 1024];
     using (MemoryStream ms = new MemoryStream())
     {
         using (Stream input = RessourceHelper.GetResourceStream(streamPath))
         {
             int read;
             while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
             {
                 ms.Write(buffer, 0, read);
             }
             return(File(ms.ToArray(), contentType));
         }
     }
 }
예제 #2
0
 /// <summary>
 /// renders the embedde image. This Action can be used as a
 /// location of the image, defined within src attribute of the <img/> tag.
 /// </summary>
 /// <param name="imagePath">an embedded dot separated path to the ressource. For example:
 /// Plupload.Net.Content.img.buttons.png</param>
 /// <returns>an ImageResult</returns>
 public ActionResult EmbeddedImage(string imagePath)
 {
     return(this.Image(RessourceHelper.GetResourceStream(imagePath), "image/" + imagePath.Substring(imagePath.LastIndexOf('.') + 1)));
 }