Skip to content

Commit

Permalink
Merge pull request #147 from RaythaHQ/dev
Browse files Browse the repository at this point in the history
Release v1.1.3
  • Loading branch information
apexdodge committed Oct 15, 2023
2 parents 7a12f56 + c2a576f commit 87eedd1
Show file tree
Hide file tree
Showing 20 changed files with 564 additions and 316 deletions.
18 changes: 4 additions & 14 deletions src/Raytha.Application/Common/Interfaces/ICSVService.cs
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface ICurrentOrganization
string HomePageType { get; }

string PathBase { get; }
string RedirectWebsite { get; }

OrganizationTimeZoneConverter TimeZoneConverter { get; }
IEnumerable<AuthenticationSchemeDto> AuthenticationSchemes { get; }
Expand Down
34 changes: 34 additions & 0 deletions src/Raytha.Application/Common/Utils/FileDownloadUtility.cs
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; }
}
}
2 changes: 1 addition & 1 deletion src/Raytha.Application/Common/Utils/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static bool IsValidDeveloperName(string source)
return !string.IsNullOrEmpty(source.ToDeveloperName()) && !IsProtectedRoutePath(source.ToDeveloperName());
}

public static bool IsValidUriFormat(string link)
public static bool IsValidUriFormat(this string link)
{
if (string.IsNullOrWhiteSpace(link))
{
Expand Down
Loading

0 comments on commit 87eedd1

Please sign in to comment.