taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

Fixed issue upload large file #191

Closed JeanBeaurepaire closed 9 years ago

JeanBeaurepaire commented 9 years ago

I found the bug. You can't upload InputStream because big files seems to plant . You need to use a File type on your files.

I added the class upload(File content), and you need to add the last version of httpclient and httpcore (4.4) , and add httpmime to your pom.xml :

org.apache.httpcomponents httpmime 4.4
<dependency>

I didn't delete upload(InpuStream content) but she is useless now .

maxkar commented 9 years ago

And what was the real cause of the problem? Is this a bug in apache commons? In redmine implementation? In some http server or proxy? In [anti]virus software on the machine?

Is this an issue with simple vs multipart post? Or is this an issue with Content-Lenght header? Resolutions could be different. Maybe creating multipart request with stream source is a better solution?

I am very suspicious about Content-Length header (and other fixed lenghts in the requests). Usually, reading file length and then sending a file is not an atomic operation. So file could be changed after its length was read. How the guilty component (if any) will behave if Content-Lenght is different from an actual conetnt length?

JeanBeaurepaire commented 9 years ago

Content-Lenght is automaticaly set , i didn't do changes about this. But multipart-request doesn't works. Only application/octet-stream works with REST Redmine api ( see doc on redmine website ) . I have found this solution because it works with my utilisation, but if you found a general utilisation better than this, you can ! :-)

keritaf commented 9 years ago

First of all, there's no pom.xml here - gradle is used to build the project, not maven (makes me wonder where have you found POM file here). Then, updating httpclient/httpcore to 4.4 breaks the build for me:

D:\projects\git\redmine-java-api-keritaf\src\main\java\com\taskadapter\redmineapi\internal\Transport.java:592: error: exception UnsupportedEncodingException is never thrown in body of corresponding try statement
                } catch (UnsupportedEncodingException e) {
                  ^

UnsupportedCharsetException is now thrown instead. And there are lots of deprecations between 4.2 and 4.4 so I propose a migration to new API.

keritaf commented 9 years ago

And could you please explain what is actually broken here?

alexeyOnGitHub commented 9 years ago

I appreciate when people help out with this library. but to keep the quality on a certain level we cannot accept pull requests that do not have tests or detailed explanation of what is wrong and how the fix will address that.

switching to newer Httpclient library (4.5.1) is not an option yet - see problems with pools in https://github.com/taskadapter/redmine-java-api/issues/212