-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from RaythaHQ/dev
Release v1.1.3
- Loading branch information
Showing
20 changed files
with
564 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CsvHelper; | ||
using System.Collections; | ||
using System.Xml; | ||
namespace Raytha.Application.Common.Interfaces; | ||
|
||
namespace Raytha.Application.Common.Interfaces | ||
public interface ICsvService | ||
{ | ||
public interface ICSVService | ||
{ | ||
public List<Dictionary<string,object>> ReadCSV<T>(Stream file); | ||
} | ||
} | ||
public IEnumerable<Dictionary<string, object>> ReadCsv<T>(Stream file); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Raytha.Application/Common/Utils/FileDownloadUtility.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Raytha.Application.Common.Utils; | ||
|
||
public static class FileDownloadUtility | ||
{ | ||
public static async Task<FileInfo> DownloadFile(string fileUrl) | ||
{ | ||
var client = new HttpClient(); | ||
var response = await client.GetAsync(fileUrl); | ||
string contentType = response.Content.Headers.ContentType.ToString(); | ||
bool isValidMimeType = FileStorageUtility.GetAllowedFileExtensionsFromConfig(FileStorageUtility.DEFAULT_ALLOWED_MIMETYPES).Any(s => s.Contains(contentType.Split('/')[0])); | ||
if (isValidMimeType && response.Content.Headers.ContentLength <= FileStorageUtility.DEFAULT_MAX_FILE_SIZE) | ||
{ | ||
string fileExt = Path.GetExtension(response.Content.Headers.ContentDisposition.FileName.ToString().Replace("\"", "")); | ||
|
||
var memoryStream = new MemoryStream(); | ||
await response.Content.CopyToAsync(memoryStream); | ||
var fileInfo = new FileInfo() | ||
{ | ||
FileMemoryStream = memoryStream, | ||
FileExt = fileExt, | ||
ContentType = contentType | ||
}; | ||
return fileInfo; | ||
} | ||
else | ||
return null; | ||
} | ||
public class FileInfo | ||
{ | ||
public MemoryStream FileMemoryStream { get; set; } | ||
public string FileExt { get; set; } | ||
public string ContentType { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.