Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System.IO;
  2. using System.Web.Http;
  3. using System.Web.Mvc;
  4.  
  5. namespace soundtube.Controllers
  6. {
  7.     [System.Web.Http.RoutePrefix("api/audio")]
  8.     public class AudioController : ApiController
  9.     {
  10.         [System.Web.Http.HttpGet]
  11.         public ActionResult GetAudioFile(string fileLocation)
  12.         {
  13.             byte[] bytes;
  14.  
  15.             using (var fs = new FileStream(fileLocation, FileMode.Open, FileAccess.Read))
  16.             {
  17.                 var br = new BinaryReader(fs);
  18.                 long numBytes = new FileInfo(fileLocation).Length;
  19.                 bytes = br.ReadBytes((int)numBytes);
  20.             }
  21.  
  22.             return File(bytes, "audio/mpeg", "callrecording.mp3");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement