Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

609 B
Raw Blame
using Microsoft.AspNetCore.Http;

namespace Grand.Web.Common.Extensions;

/// <summary>
///     Storage extensions
/// </summary>
public static class Extensions
{
    /// <summary>
    ///     Gets the download binary array
    /// </summary>
    /// <param name="file">Posted file</param>
    /// <returns>Download binary array</returns>
    public static byte[] GetDownloadBits(this IFormFile file)
    {
        using var fileStream = file.OpenReadStream();
        using var ms = new MemoryStream();
        fileStream.CopyTo(ms);
        var fileBytes = ms.ToArray();
        return fileBytes;
    }
}