Skip to content
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

Add several files in multipart #117

Open
auriou opened this issue Nov 29, 2020 · 0 comments
Open

Add several files in multipart #117

auriou opened this issue Nov 29, 2020 · 0 comments

Comments

@auriou
Copy link

auriou commented Nov 29, 2020

add multiple files dynamically

public IMultipartFromDataRequest AddFiles(List<FileMultiPart> files)
{
    foreach (var file in files)
    {
        AddByteArray(file.Bytes, file.Name, file.FileName, file.ContentType);
    }

    return this;
}

public class FileMultiPart
{
    public string Name { get; set; }
    public string FileName { get; set; }
    public string ContentType { get; set; }
    public byte[] Bytes { get; set; }

    public FileMultiPart(string name, string fileName, byte[] bytes, string contentType = null)
    {
        Name = name;
        FileName = fileName;
        Bytes = bytes;
        ContentType = contentType;
    }

    public static List<FileMultiPart> Factory(string name, List<KeyValuePair<string, byte[]>> fileKeyValuePairs) =>
        fileKeyValuePairs.Select(p => new FileMultiPart(name, p.Key, p.Value))
            .ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant