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

Make @Part supporting filename property #1179

Closed
jeaking opened this issue Oct 8, 2015 · 1 comment
Closed

Make @Part supporting filename property #1179

jeaking opened this issue Oct 8, 2015 · 1 comment

Comments

@jeaking
Copy link

jeaking commented Oct 8, 2015

I am using Retrofit 2 in my application, it is great and very easy to learn. But I still met some issues when I tried to uploading files using Retrofit 2, the biggest one is that I didn't know how to specify the filename of uploading file. I finally got a solution by googling, it looks like this:

@POST("client/resources/upload/image")
@Multipart
Call<ResponseBody> upload(@Part("myFile\"; filename=\"myFile.png") RequestBody myFile); 

It work for me, but in my opinion this looks more like a work around, I think there should be another solution which is more elegant and straightforward.

I suggest to add a new property named "filename" to @part as following:

@documented
@target(PARAMETER)
@retention(RUNTIME)
public @interface Part {
String value();
String filename() default "";
/** The {@code Content-Transfer-Encoding} of this part. */
String encoding() default "binary";
}

Is this acceptable?Or any comments on this?

Thanks!

@JakeWharton
Copy link
Member

This prevents the filename from being set dynamically which will make the feature not useful to most users. Please contribute discussion on #1140.

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

2 participants