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

Expose http response content headers via Box SDK #796

Open
Yosif-Smint opened this issue Jan 21, 2022 · 1 comment
Open

Expose http response content headers via Box SDK #796

Yosif-Smint opened this issue Jan 21, 2022 · 1 comment
Assignees

Comments

@Yosif-Smint
Copy link

Yosif-Smint commented Jan 21, 2022

Is your feature request related to a problem? Please describe.

The problem that I am facing is that BoxFilesManager does not provide an API for getting System.IO.Stream related information.
It does not expose 'content-type', 'content-length' nor 'content-disposition' content request headers.

Why am I requesting this?
Box API does not return any whatsoever mime-types.
I don't want to guess the mime-type or parse it on the fly based on the file extension of a BoxFile.
Working with generic mime types could introduce security issues.
I would prefer If I can return the correct mime type to the front-end, so that the browsers knows how to handle it correctly.

Would be happy to hear from you or answer questions.
Thanks!

Describe the solution you'd like

See Box.V2.IBoxResponse

public interface IBoxResponse<T> where T : class
{
    ...

    HttpResponseHeaders Headers { get; set; }

    /// <summary>
    /// This could be added
    /// </summary>
    HttpContentHeaders ContentHeaders { get; set; }
}
See Box.V2.Request.HttpRequestHandler line 204 on the main branch

var boxResponse = new BoxResponse<T>
{
    Headers = response.Headers,
    ContentHeaders = response.Content.Headers, 

    // Translate the status codes that interest us 
    StatusCode = response.StatusCode
};

Afterwards we can introduce a new set of BoxFilesManager methods that can return the response itself IBoxResponse<> or we can create a custom return type. No preference about that.
E.g.

Task<IBoxResponse<Stream>> DownloadStreamAsync(string id, string ...)
@mwwoda
Copy link
Contributor

mwwoda commented Jan 24, 2022

Hi @Yosif-Smint

Thanks for the suggestion! We'll look into it.

Thanks
@mwwoda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants