Skip to content

Commit c3a0a9d

Browse files
committed
TD-3311: Removed special characters in filename during file upload
1 parent 1671aeb commit c3a0a9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

LearningHub.Nhs.WebUI/Services/ContributeService.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Net.Http;
88
using System.Text;
9+
using System.Text.RegularExpressions;
910
using System.Threading.Tasks;
1011
using LearningHub.Nhs.Models.Common;
1112
using LearningHub.Nhs.Models.Enums;
@@ -1240,6 +1241,9 @@ public async Task<FileChunkUploadResult> UploadFileChunkAsync(int fileChunkDetai
12401241
{
12411242
if (fileChunkDetailId == 0)
12421243
{
1244+
// removing special characters in file name
1245+
string fileNameUpdated = Regex.Replace(fileName, "[^a-zA-Z0-9.]", string.Empty);
1246+
12431247
// Store the chunk
12441248
var filelocation = string.Empty;
12451249
var directoryRef = "chunks_" + Guid.NewGuid().ToString();
@@ -1256,7 +1260,7 @@ public async Task<FileChunkUploadResult> UploadFileChunkAsync(int fileChunkDetai
12561260
FilePath = filelocation,
12571261
ChunkCount = chunkCount,
12581262
ResourceVersionId = (resourceVersionId == 0) ? (int?)null : resourceVersionId,
1259-
FileName = fileName,
1263+
FileName = fileNameUpdated,
12601264
FileSizeKb = (int)(fileSize / 1000),
12611265
});
12621266
}

0 commit comments

Comments
 (0)