8000 Retrofit multipart form support · Issue #2 · Jaguar-dart/client · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Retrofit multipart form support #2

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

Closed
jaumard opened this issue Aug 28, 2018 · 11 comments · Fixed by #6
Closed

Retrofit multipart form support #2

jaumard opened this issue Aug 28, 2018 · 11 comments · Fixed by #6

Comments

@jaumard
Copy link
Contributor
jaumard commented Aug 28, 2018

Hey @tejainece what the plan for this, of course I want to try the lib and first call I need to implement (login) is in form data lol
Can you tell me the steps and I'll do a PR for this :)

Do we go for a @AsFormData annotation ?

@kevin-sakemaer
Copy link
Member

I think it should into the @GetReq and friend annotation

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

Hum strange as it's a post request not a get, that's why I was proposing AsMultipart like the AsJson already present

@kevin-sakemaer
Copy link
Member

That's right since it's a parameters it must be the same as @AsJson :)

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

Ok :) I'll dig into this then see if I'm able to make a PR thx

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

It might need changes to jaguar_serializer too, as for multipart we need Map<String, String> not Map<String, dynamic>, so jaguar_serializer should be able to serialize for multipart.
How does it sound ?

@kevin-sakemaer
Copy link
Member

that should not be a problem for jaguar_serializer
juste use a class like this :

class Multipart {
  String field;
  String field2;
  //..etc
}

@kevin-sakemaer
Copy link
Member

in the example of retrofit the user model is also a Map<String, String>

@tejainece
Copy link
Member

@jaumard @AsForm, @AsFormField, @AsMultipart, @AsMultipartField should be good.

jaguar_serializer can handle Map<String, String>.

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

@kleak @tejainece the problem here is for example:

class User {
   int age;
  String name;
}

This will not cast to Map<String, String> but under a multipart data it will need to be. I was thinking to generate a toStringMap that will transform all fields to String automatically

@jaumard
Copy link
Contributor Author
jaumard commented Aug 28, 2018

My current code for the multipart support generate this:

Future<LoginResponse> login(LoginRequest request) async {
    var req = base.post.path("/login").multipart(serializers.to(request));
    return req.one(convert: serializers.oneFrom);
  }

but this code give me type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, String>'

@tejainece
Copy link
Member

@jaumard I have added url-encoded-form support c3ba261

But I have not fixed multipart form yet.

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

Successfully merging a pull request may close this issue.

3 participants
0