-
Notifications
You must be signed in to change notification settings - Fork 368
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
Allow uploading files from InputStreams and Files #544
Conversation
@drake-stripe Can you take a look at the failed build before we find you a reviewer? It looks like checkstyle is failing:
Also, this is a bit of a nit, but those of us who work on these external projects tend to try to keep slightly better commit hygiene than what you might see internally. It might be slightly better to get into a workflow where you pull minor changes/fixes into a single commit with Thanks for taking a crack at this! |
@drake-stripe Looks good overall, but you'll need to fix the style errors as Brandur mentioned above. You can run both the test suite and the linter locally with Also, could you add a test case in the functional test for |
797e0f7
to
151ea9b
Compare
PR now passes linter, and there is a functional test implemented for InputStream uploading. I also squashed it into one commit with a more descriptive commit message. |
+ "\"; filename=\"" + fileName + "\"").append( | ||
LINE_BREAK); | ||
addFileField(name, file.getName(), new FileInputStream(file)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but since these methods are meant to be internal anyway, can we just get rid of the File
form of addFileField
since it's only used in one place anyway? If other places in the library need to do this, they can instantiate their own FileInputStream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Left a minor comment, but thanks a lot for fixing all that stuff Drake! (Olivier, you're a lot better learned in Java than I am, so I'll leave a final review to you.) |
c17bede
to
e9b3f4e
Compare
This commit adds in suppor for calling FileUpload.create(Map<String, Object>) with the parameter "file" set to an InputStream, instead of only allowing Files. You can see an example of this in src/test/java/com/stripe/functional/FileUploadTest.java. Furthermore, this commit changes the addFileField method to no longer accept a file argument, and only allows for InputStream arguments in addition to a string containing the name of the file to upload.
e9b3f4e
to
9247989
Compare
Released in 5.48.0. |
This allows users to create a FileUpload with either a
File
or aInputStream
under thefile
parameter. It defaults to calling the uploaded file "blob".#299