Skip to content

Fix smart thumbnails for image files with uppercase extension #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions jQuery-File-Upload.MVC3/Upload/FilesStatus.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using System;
using System.IO;
using System.Linq;

namespace jQuery_File_Upload.MVC3.Upload
{
public class FilesStatus
{
public class FilesStatus
{
private static readonly string[] ImageExtensions = new[]
{
".gif", ".jpg", ".png"
};

public const string HandlerPath = "/Upload/";

public string group { get; set; }
Expand Down Expand Up @@ -41,11 +47,13 @@ private void SetValues(string fileName, int fileLength, string fullPath)
else thumbnail_url = @"data:image/png;base64," + EncodeFile(fullPath);
}

private bool IsImage(string ext)
{
return ext == ".gif" || ext == ".jpg" || ext == ".png";
}

private bool IsImage(string ext)
{
string lowercaseExtension = ext.ToLowerInvariant();

return ImageExtensions.Contains(lowercaseExtension);
}

private string EncodeFile(string fileName)
{
return Convert.ToBase64String(System.IO.File.ReadAllBytes(fileName));
Expand Down