You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stepan Koltsov (JIRA)" <ji...@apache.org> on 2008/05/28 19:29:45 UTC
[jira] Created: (FILEUPLOAD-159) MultipartStream.position method
MultipartStream.position method
-------------------------------
Key: FILEUPLOAD-159
URL: https://issues.apache.org/jira/browse/FILEUPLOAD-159
Project: Commons FileUpload
Issue Type: Improvement
Affects Versions: Nightly Builds
Reporter: Stepan Koltsov
Attached patch adds MultipartStream.position() method, that returns current position withing InputStream plus offset in buffer. I. e. current parser position.
Use case is parsing multipart that is stored as file on disk: at first run we read that file and saving part offsets (by calling position() methods). Then we can randomly access all parts without storing parts as separate files on disk.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (FILEUPLOAD-159) MultipartStream.position method
Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-159?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stepan Koltsov updated FILEUPLOAD-159:
--------------------------------------
Attachment: commons-fileupload-position-2008-05-28.diff
Patch.
> MultipartStream.position method
> -------------------------------
>
> Key: FILEUPLOAD-159
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-159
> Project: Commons FileUpload
> Issue Type: Improvement
> Affects Versions: Nightly Builds
> Reporter: Stepan Koltsov
> Attachments: commons-fileupload-position-2008-05-28.diff
>
>
> Attached patch adds MultipartStream.position() method, that returns current position withing InputStream plus offset in buffer. I. e. current parser position.
> Use case is parsing multipart that is stored as file on disk: at first run we read that file and saving part offsets (by calling position() methods). Then we can randomly access all parts without storing parts as separate files on disk.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (FILEUPLOAD-159) MultipartStream.position method
Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12664902#action_12664902 ]
Jochen Wiedmann commented on FILEUPLOAD-159:
--------------------------------------------
A question on your patch: Why is position incremented twice in read()?
> MultipartStream.position method
> -------------------------------
>
> Key: FILEUPLOAD-159
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-159
> Project: Commons FileUpload
> Issue Type: Improvement
> Affects Versions: Nightly Builds
> Reporter: Stepan Koltsov
> Attachments: commons-fileupload-position-2008-05-28.diff
>
>
> Attached patch adds MultipartStream.position() method, that returns current position withing InputStream plus offset in buffer. I. e. current parser position.
> Use case is parsing multipart that is stored as file on disk: at first run we read that file and saving part offsets (by calling position() methods). Then we can randomly access all parts without storing parts as separate files on disk.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (FILEUPLOAD-159) MultipartStream.position method
Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FILEUPLOAD-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12664912#action_12664912 ]
Stepan Koltsov commented on FILEUPLOAD-159:
-------------------------------------------
Seems like it is a bug.
I think "int read()" is not really needed (because, most users call "read(byte[], ...)" methods).
I propose refactoring of read() method to
{code}
int read() {
byte[] buffer = new byte[1];
int count = read(buffer);
if (count < 0) return -1;
if (count == 0) throw new Error(); // read(byte[]) method is not allowed to return 0
return buffer[0] & 0xFF;
}
{code}
It is a bit slower, but avoids code duplication between read methods.
> MultipartStream.position method
> -------------------------------
>
> Key: FILEUPLOAD-159
> URL: https://issues.apache.org/jira/browse/FILEUPLOAD-159
> Project: Commons FileUpload
> Issue Type: Improvement
> Affects Versions: Nightly Builds
> Reporter: Stepan Koltsov
> Attachments: commons-fileupload-position-2008-05-28.diff
>
>
> Attached patch adds MultipartStream.position() method, that returns current position withing InputStream plus offset in buffer. I. e. current parser position.
> Use case is parsing multipart that is stored as file on disk: at first run we read that file and saving part offsets (by calling position() methods). Then we can randomly access all parts without storing parts as separate files on disk.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.