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 support for sending files as raw HTTP bodies #137

Open
3 of 6 tasks
edeckers opened this issue Mar 21, 2021 · 2 comments · May be fixed by #141
Open
3 of 6 tasks

Add support for sending files as raw HTTP bodies #137

edeckers opened this issue Mar 21, 2021 · 2 comments · May be fixed by #141
Projects
Milestone

Comments

@edeckers
Copy link
Owner

edeckers commented Mar 21, 2021

Originally suggested by @pke in #135

Currently react-native-blob-courier supports multipart file uploads only, but there are situations where it is desirable to send a file to the server as a raw HTTP body.

Proposed solution
Add a send(request:SendRequest) method to TypeScript code base, inspired by HttpClient.Send.

SendRequest would look something like:

interface SendRequest {
  method:string;
  absolutePath:string;
  headers:dictionary;
  returnResponse: boolean;
}

Progress

  • Add send(request:SendRequest) method to TypeScript code base
  • Add a send(method:string,absolutePath:string,headers:dictionary) method to Android code base
  • Add a send(method:string,absolutePath:string,headers:dictionary) method to iOS code base
  • Add TypeScript tests
  • Add Android tests
  • Add iOS tests
@pke
Copy link

pke commented Mar 21, 2021

Why not use fetch's RequestInit as input? it contains all the fields already and could be extended to add fileURI as a new prop.
Remember headers in the true HTTP protocol sense is not just a dictionary because there could be multiple named headers.

@edeckers
Copy link
Owner Author

edeckers commented Mar 22, 2021

Good catch, and you're absolutely right, however: for the request interfaces I already take inspiration from fetch and fetch does actually treat headers as a dictionary and combines duplicate headers into a comma separated list[1],[2], so I'm sticking with that.

Using RequestInit is a good suggestion as well, but it contains fields that aren't supported by the native code base yet and possibly ever. So that would communicate false expectations to users of the library.

@edeckers edeckers linked a pull request Mar 29, 2021 that will close this issue
@edeckers edeckers moved this from Backlog to In progress in Planned Apr 3, 2021
@edeckers edeckers added this to the 1.1.2 milestone Apr 24, 2021
@edeckers edeckers modified the milestones: 1.1.2, 1.1.3 Jul 3, 2021
@edeckers edeckers modified the milestones: 2.0.3, 2.0.4, 2.0.5 Aug 22, 2021
@edeckers edeckers modified the milestones: 2.0.5, 2.0.8 Nov 21, 2021
@edeckers edeckers modified the milestones: 3.0.1, 3.0.4, 3.0.3 Dec 22, 2021
@edeckers edeckers modified the milestones: 3.0.3, 3.0.4 Dec 29, 2021
@edeckers edeckers modified the milestones: 3.0.4, 3.0.6 Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Planned
  
In progress
Development

Successfully merging a pull request may close this issue.

2 participants