wiki:ownCloud-shared-links-access

Accessing Own Cloud Files

To access files the user shares over a link, some hints could prove useful to save time in doing so

  • How to download the folder the user shared publicly
  • How to unpack that zip in Java (and how not to)
  • (TODO: how to upload files back if the user allows it)

How to download files

The user has the possibility to share his/her files over a link. Unfortunately the files can not directly be accessed over this link, but by adding a parameter to the link, they complete folder can be downloaded as a zip file. An Example would be

https://clarin.fz-juelich.de/owncloud/public.php?service=files&t=76027110ab537d125ec2e77a0cc447fa

which then becomes

https://clarin.fz-juelich.de/owncloud/public.php?service=files&t=76027110ab537d125ec2e77a0cc447fa&download

The zip file that is linked then can be downloaded by a normal GET request to the server.

How to unpack zip in Java

The problem, at least with Java, is that the "version" of the ZIP file (I don't know if this is just a software or a specification issue) can not be unzipped using Java. When using 'file' to determine the file type it says:

Zip archive data, at least v3.0 to extract

The error that is thrown is

 java.util.zip.ZipException: invalid LOC header (bad signature) 

Unfortunately, the standard ZIP-library in Java is only able to unpack successfully to v2.0. Whatever this means (I couldn't find out, but if anybody has an idea, feel free to add it).

Though I was able to use the Linux command line tool unzip (UnZip? 6.00 of 20 April 2009) the file successfully. So there at least exists a work around.

(TODO how to upload files back to owncloud (if the user marks the right check box))

Last modified 9 years ago Last modified on 10/30/15 10:54:28