Skip to content

Commit e7b3406

Browse files
author
Abhishek Kumar Singh
committed
Merged PR 3: After Adding the Relative Path to all the paths like UploadedFiles and Documentation
2 parents caa7970 + 3948889 commit e7b3406

File tree

6 files changed

+80
-7
lines changed

6 files changed

+80
-7
lines changed

File Server/Controllers/FileController.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public HttpResponseMessage GetDocumentation()
4646
// 1) Documentation Path
4747

4848
//var filename = "file.pptx";
49-
//var filepath = HttpContext.Current.Server.MapPath($"~/App_Data/{filename}");
50-
var DocumentationPath = ConfigurationManager.AppSettings["DocumentationPath"];
49+
//var DocumentationPath = HttpContext.Current.Server.MapPath($"~/App_Data/{filename}");
50+
var relativePath = ConfigurationManager.AppSettings["DocumentationPath"];
51+
var DocumentationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath);
5152

5253
//Read the File into a Byte Array.
5354
byte[] bytes = File.ReadAllBytes(DocumentationPath);
@@ -93,7 +94,10 @@ public async Task<HttpResponseMessage> Post_File_PInvoke_Return_File()
9394
try
9495
{
9596
//Any size, and extension of a file can be read and uploaded in the Uploaded Folder
96-
var fileuploadPath = ConfigurationManager.AppSettings["UploadFile"];
97+
//var fileuploadPath = ConfigurationManager.AppSettings["UploadFile"];
98+
var relativePath = ConfigurationManager.AppSettings["UploadFile"];
99+
var fileuploadPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath);
100+
97101

98102
var provider = new MultipartFormDataStreamProvider(fileuploadPath);
99103
var content = new StreamContent(HttpContext.Current.Request.GetBufferlessInputStream(true));
@@ -129,8 +133,7 @@ public async Task<HttpResponseMessage> Post_File_PInvoke_Return_File()
129133
//Create HTTP Response.
130134
var response = new HttpResponseMessage(HttpStatusCode.OK);
131135

132-
// 1) Documentation Path
133-
136+
// 1) Uploaded File Path
134137
//Read the File into a Byte Array.
135138
byte[] bytes = File.ReadAllBytes(UploadedFilePath);
136139

935 KB
Binary file not shown.

File Server/File Server.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<Content Include="hcci_icon.ico" />
153153
<Content Include="Scripts\bootstrap.js" />
154154
<Content Include="Scripts\bootstrap.min.js" />
155+
<Content Include="Documentation\File Server.pptx" />
155156
<None Include="Scripts\jquery-3.3.1.intellisense.js" />
156157
<Content Include="Scripts\jquery-3.3.1.js" />
157158
<Content Include="Scripts\jquery-3.3.1.min.js" />
@@ -182,6 +183,7 @@
182183
</ItemGroup>
183184
<ItemGroup>
184185
<Folder Include="App_Data\" />
186+
<Folder Include="UploadedFiles\" />
185187
</ItemGroup>
186188
<ItemGroup>
187189
<Content Include="fonts\glyphicons-halflings-regular.woff2" />

File Server/Web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<add key="ClientValidationEnabled" value="true"/>
1111
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
1212
<!--Folder where we upload the files-->
13-
<add key="UploadFile" value="C:\Users\abhi\Desktop\File Server - v1.0\File Server\UploadedFiles"/>
13+
<add key="UploadFile" value="UploadedFiles"/>
1414
<!--Documentaion File Path-->
15-
<add key="DocumentationPath" value="C:\Users\abhi\Desktop\Documentation of File Server\File Server.pptx"/>
15+
<add key="DocumentationPath" value="Documentation/File Server.pptx"/>
1616

1717
</appSettings>
1818
<system.web>

azure-pipelines-1.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ASP.NET Core (.NET Framework)
2+
# Build and test ASP.NET Core projects targeting the full .NET Framework.
3+
# Add steps that publish symbols, save build artifacts, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5+
6+
trigger:
7+
- main
8+
9+
pool:
10+
vmImage: 'windows-latest'
11+
12+
variables:
13+
solution: '**/*.sln'
14+
buildPlatform: 'Any CPU'
15+
buildConfiguration: 'Release'
16+
17+
steps:
18+
- task: NuGetToolInstaller@1
19+
20+
- task: NuGetCommand@2
21+
inputs:
22+
restoreSolution: '$(solution)'
23+
24+
- task: VSBuild@1
25+
inputs:
26+
solution: '$(solution)'
27+
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
28+
platform: '$(buildPlatform)'
29+
configuration: '$(buildConfiguration)'
30+
31+
- task: VSTest@2
32+
inputs:
33+
platform: '$(buildPlatform)'
34+
configuration: '$(buildConfiguration)'

azure-pipelines.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ASP.NET Core (.NET Framework)
2+
# Build and test ASP.NET Core projects targeting the full .NET Framework.
3+
# Add steps that publish symbols, save build artifacts, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5+
6+
trigger:
7+
- main
8+
9+
pool:
10+
vmImage: 'windows-latest'
11+
12+
variables:
13+
solution: '**/*.sln'
14+
buildPlatform: 'Any CPU'
15+
buildConfiguration: 'Release'
16+
17+
steps:
18+
- task: NuGetToolInstaller@1
19+
20+
- task: NuGetCommand@2
21+
inputs:
22+
restoreSolution: '$(solution)'
23+
24+
- task: VSBuild@1
25+
inputs:
26+
solution: '$(solution)'
27+
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
28+
platform: '$(buildPlatform)'
29+
configuration: '$(buildConfiguration)'
30+
31+
- task: VSTest@2
32+
inputs:
33+
platform: '$(buildPlatform)'
34+
configuration: '$(buildConfiguration)'

0 commit comments

Comments
 (0)