commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mario Ivankovits (JIRA)" <j...@apache.org>
Subject [jira] Commented: (VFS-116) Add Write capability to RandomAccessContent for all providers
Date Mon, 19 Mar 2007 20:03:32 GMT

    [ https://issues.apache.org/jira/browse/VFS-116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482198
] 

Mario Ivankovits commented on VFS-116:
--------------------------------------

I've had a deeper look at your patch now, and I'd say it do not do what I think it should
do ;-)

You simply request the outputStream using
mout = fileObject.getOutputStream();
without honoring the current filePointer.
Which means you'll always start overwriting the file.

Also a true random output content has to provide thinks like

seek(1000)
write("a")
seek(2000)
write("b")
seek(1500)
write("c")

which I suspect would really work with at least http/ftp server, don't know if sftp has such
an enhanced protocol.

For your use case you simply could request an outputStream through FileObject.getContent(),
no?

Ciao,
Mario

> Add Write capability to RandomAccessContent for all providers
> -------------------------------------------------------------
>
>                 Key: VFS-116
>                 URL: https://issues.apache.org/jira/browse/VFS-116
>             Project: Commons VFS
>          Issue Type: Improvement
>    Affects Versions: 1.0, 1.1
>         Environment: Java 1.5 / any os
>            Reporter: Andrew Serff
>         Attachments: AbstractRandomAccessStreamContent.java, FtpFileProvider.java, FtpRandomAccessContent.java,
HttpRandomAccesContent.java, SftpFileProvider.java, SftpRandomAccessContent.java, svn_diff.txt
>
>
> Writing to RandomAccessContent seems to only work for the File provider.  Reading works
for all it seems, just not writing.  The main ones I'm worried about are ftp and sftp.  Here
is what I know:
> FtpRandomAccessContent and SftpRandomAccessContent both extend from AbstractRandomAccessStreamContent.
 (The Http one does too, but I'm not interested in that one right now.)
> AbstractRandomAccessStreamContent extends from RandomAccessContent which only exposes
the read methods and throws UnsupportedOperationExceptions for all the write methods.  
> If you just add the write methods to AbstractRandomAccessStreamContent (calling getDataOutputStream().write*(v))
and then add an abstract method getDataOutputStream() to it, the subclasses will need to implement
that.  
> You also need to add the RANDOM_ACCESS_WRITE Capability to the SFTP and FTP FileProviders.
 
> I have been trying to do this tonight but I'm not having much luck with getting anything
to write with both FTP and SFTP.  I'm unfamiliar with JSch and Commons FTP, so I might just
be missing something.  If anyone could help, I'd be glad to submit a fix for this "Improvement"
issue.  I will either attach my changed files or add some comments to this issue to show the
changes I have made.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message