fcatae / Arda

Arda is an open source tool designed to manage team workloads.
42 stars 19 forks source link

Photo: Lots of issues with pictures #74

Closed fcatae closed 7 years ago

fcatae commented 7 years ago

This is the top 1 issue in Exceptions and HTTP 500. There are problems related to invalid names, lots of calls (200+), redis timeout, etc. Already implemented caching in Arda.Main, but we are still having problems.

fcatae commented 7 years ago

Problem found: Picture returns text rather than binary (jpeg/png).

fcatae commented 7 years ago

Ensure the picture is returned as a file:

string data = Util.GetUserPhotoString(user);

string[] components = data.Split(',');

int typePhotoStart = components[0].IndexOf(":") + 1;
int typePhotoEnd = components[0].IndexOf(";");
string encodedPhoto = components[1];

string typePhoto = components[0].Substring(typePhotoStart, typePhotoEnd - typePhotoStart);
byte[] binaryPhoto = Convert.FromBase64String(encodedPhoto);
var streamPhoto = new MemoryStream(binaryPhoto);

return new FileStreamResult(streamPhoto, typePhoto);

instead of just

Util.GetUserPhotoString(user);
fcatae commented 7 years ago

Replace the client-side reference:

    var url = '/users/photo/' + user;
    $.ajax({
        url: url,
        type: "GET",
        cache: true,
        success: function (data) {
            img = $('<img class="user">').attr('src', data);
            $('#' + taskId + ' .folder-tasks .folder-footer').append(img);
        }
    });

to a simple:

    var url = '/users/photo/' + user;
    img = $('<img class="user">').attr('src', url);
    $('#' + taskId + ' .folder-tasks .folder-footer').append(img);
fcatae commented 7 years ago

@allantargino Finalmente resolvido o problema de carregamento de imagem. Depois faz um refresh e veja como ficou rapido. :)

fcatae commented 7 years ago

Closing the issue. The pictures are very fast and stable.