Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Web.Http;
- using System.Web.Mvc;
- namespace soundtube.Controllers
- {
- [System.Web.Http.RoutePrefix("api/audio")]
- public class AudioController : ApiController
- {
- [System.Web.Http.HttpGet]
- public ActionResult GetAudioFile(string fileLocation)
- {
- byte[] bytes;
- using (var fs = new FileStream(fileLocation, FileMode.Open, FileAccess.Read))
- {
- var br = new BinaryReader(fs);
- long numBytes = new FileInfo(fileLocation).Length;
- bytes = br.ReadBytes((int)numBytes);
- }
- return File(bytes, "audio/mpeg", "callrecording.mp3");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement