Skip to content

Commit 0810f37

Browse files
authored
Merge pull request #119 from Gid733/master
Added audio element
2 parents 1e9cccb + 8791631 commit 0810f37

File tree

14 files changed

+42
-9
lines changed

14 files changed

+42
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,5 @@ eform-client/src/app/plugins/modules/
371371

372372
eFormAPI/Plugins/
373373
eFormAPI/eFormAPI/Areas/HelpPage/HelpPage.css
374+
375+
eFormAPI/eFormAPI/output/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.IO;
2+
using System.Net;
3+
using System.Net.Http;
4+
using System.Net.Http.Headers;
5+
using System.Web;
6+
using System.Web.Http;
7+
8+
namespace eFormAPI.Web.Controllers
9+
{
10+
[Authorize]
11+
public class AudioController : ApiController
12+
{
13+
[HttpGet]
14+
[Route("api/audio/eform-audio")]
15+
public HttpResponseMessage GetAudio(string fileName)
16+
{
17+
var filePath = HttpContext.Current.Server.MapPath($"~/output/datafolder/picture/{fileName}");
18+
if (!File.Exists(filePath))
19+
{
20+
return new HttpResponseMessage(HttpStatusCode.NotFound);
21+
}
22+
23+
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
24+
var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
25+
result.Content = new StreamContent(stream);
26+
result.Content.Headers.ContentType =
27+
new MediaTypeHeaderValue("application/octet-stream");
28+
result.Content.Headers.ContentLength = stream.Length;
29+
result.Content.Headers.ContentRange = new ContentRangeHeaderValue(0, stream.Length);
30+
return result;
31+
}
32+
}
33+
}

eFormAPI/eFormAPI/Global.asax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected void Application_Start()
3030
try
3131
{
3232
var configuration = WebConfigurationManager.OpenWebConfiguration("~");
33-
var section = (ConnectionStringsSection)configuration.GetSection("connectionStrings");
33+
var section = (ConnectionStringsSection) configuration.GetSection("connectionStrings");
3434
var connString = section.ConnectionStrings["eFormMainConnection"].ConnectionString;
3535
if (!connString.IsNullOrEmpty())
3636
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

eFormAPI/eFormAPI/eFormAPI.Web.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
<Compile Include="Controllers\CasesController.cs" />
263263
<Compile Include="Controllers\EntitySelectController.cs" />
264264
<Compile Include="Controllers\EntitySearchController.cs" />
265+
<Compile Include="Controllers\AudioController.cs" />
265266
<Compile Include="Controllers\ImagesController.cs" />
266267
<Compile Include="Controllers\SettingsController.cs" />
267268
<Compile Include="Controllers\TagsController.cs" />

0 commit comments

Comments
 (0)