ShareX / ShareX

ShareX is a free and open source program that lets you capture or record any area of your screen and share it with a single press of a key. It also allows uploading images, text or other types of files to many supported destinations you can choose from.
https://getsharex.com
GNU General Public License v3.0
28.11k stars 3.1k forks source link

ownCloud support #185

Closed jancborchardt closed 9 years ago

jancborchardt commented 9 years ago

Supporting ownCloud https://owncloud.org would be cool – it’s a self-hosted data sync platform. It supports WebDAV, so you can support multiple other platforms directly.

In addition you can use the Share API for sharing functionality: http://doc.owncloud.org/server/7.0/developer_manual/core/ocs-share-api.html

cc @brantje

Jaex commented 9 years ago

It would be difficult for me to implement it because need to host local server etc. for be able to test it. Also i'm not exactly sure how ownCloud works.

brantje commented 9 years ago

Server won't be a problem. I offer you a vps with ssh and http. Both on custom ports

jancborchardt commented 9 years ago

You can test with http://demo.owncloud.org :)

Jaex commented 9 years ago

I can't find upload method in here, Create a new Share not contains file field.

Am i need to search it in here? This is extremly long it can take days for me to read it.

brantje commented 9 years ago

I can make a simple app that does the receiving part and giving a url back.

Jaex commented 9 years ago

Document here http://doc.owncloud.org/server/7.0/developer_manual/core/ocs-share-api.html lacks greatly i don't know how to implement it. Both login system and uploading.

brantje commented 9 years ago

I guess uploading will be something like http (s):// < user>:< pass > @ owncloud / < pathwhere uploader is > I think @jancborchardt can tell you more.

Jaex commented 9 years ago

I tried using custom uploader in http://demo.owncloud.org/ using test:test@ but still it was giving authorization error:

Now i will try to set username/password in headers without use custom uploader.

Also i'm not sure is file form name is "file" or not because documentation not mentions it.

brantje commented 9 years ago

I think you can't write in the demo app. If you need an account, i can give you one.

Jaex commented 9 years ago

I can upload in demo app in web site.

Jaex commented 9 years ago

I tried this: 9718c5349bb3c183821f6c3f21d31383f8f281cf

But look like that share method for share already uploaded file. So i still can't find where is upload method.

brantje commented 9 years ago

https://github.com/owncloud/mirall This is the repo of the ownCloud client (windows/linux/etc). I don't know any C++ but here is a file that does some 'uploading' https://github.com/owncloud/mirall/blob/4759429702174a6a1ccfc4ab153ab11640f93cce/src/mirall/propagator_legacy.cpp#L223

Jaex commented 9 years ago

I don't know C++ too.

jancborchardt commented 9 years ago

@PVince81 @schiesbn can you help with this Share API question?

Jaex commented 9 years ago

Now i'm checking webdav: http://www.webdav.org/specs/

Again wall of texts: http://www.webdav.org/specs/rfc4918.html

PVince81 commented 9 years ago

Try a simple HTTP POST upload to http://host/owncloud/remote.php/webdav/subdirname

Use the same auth.

Jaex commented 9 years ago

I tried this: https://dl.dropboxusercontent.com/u/14076298/ShareX/2014/07/aIX6MYY8cX.png

and response was: The remote server returned an error: (404) Not Found. (https://dl.dropboxusercontent.com/u/14076298/ShareX/2014/07/Fi2IIg4XU4.txt)

PVince81 commented 9 years ago

Looks like you need to use the PUT method instead of POST for upload.

Please also check whether you need an extra "/" at the end if the URL.

PVince81 commented 9 years ago

Also please remove "owncloud/" from the URL. It was just an example. If owncloud us installed in the root, then the URL is http://myserver/remote.php/webdav/

Jaex commented 9 years ago

Using PUT method and URL ends with "/": http://demo.owncloud.org/remote.php/webdav/

Response is: The remote server returned an error: (409) Conflict.

Source code: https://github.com/ShareX/ShareX/blob/master/UploadersLib/FileUploaders/OwnCloud.cs

PVince81 commented 9 years ago

Good progress ! :smile:

You get 409 because the file with that name already exists on the server.

Maybe try with another file name.

Ideally the uploader could try adding a (2) when getting 409. Not sure what your other uploaders do in such cases.

PVince81 commented 9 years ago

I forgot to tell you that you need to append the file name in the URL:

http://server/remote.PHP/webdav/filename.txt

Jaex commented 9 years ago

Thanks @PVince81 now upload works after add filename to URL.

And it shows up in here too: http://demo.owncloud.org/index.php/apps/files

But when i click image there it not showing preview also don't have thumbnail but i can download it and be able to open it fine, weird.

By the way i didn't noticed you left irc before and was keep writing there to you :P

Edit: Is it intended not having response after successfull upload in webdav? So i can know it is success and then call share api to get URL.

PVince81 commented 9 years ago

Congratulations!

The preview issue could be a bug on that version of ownCloud. Most important is that if you download the file in the web ui it gives the same content.

After upload you should get a 200 I think, or possibly a WebDAV multi status response code 207 with an XML response that contains a 200.

I left IRC a while ago, sorry.

brantje commented 9 years ago

I gave him access to my dev server running oc 7 RC1. He uploaded something and this was the result (and it worked!)

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
 </meta>
 <data>
  <id>1</id>
  <url>http://home.ccc.com:8090/core/public.php?service=files&amp;t=1754d29256954f9d2b7772d6ff9ec714</url>
  <token>1754d29256954f9d2b7772d6ff9ec714</token>
 </data>
</ocs>

Only the image is corrupted...

Jaex commented 9 years ago

Now there is one problem uploaded image becomes corrupt: http://home.brantje.com:8090/core/public.php?service=files&t=a47e03f1b98848121160d60c4234a5e9

Because it contains:

But for last 5-6 years i'm using this same multipart form data request function i wrote for entire uploaders and never uploaded corrupted file before, so I'm not sure what is wrong?

jancborchardt commented 9 years ago

@Jaex since the issue is closed, is there a ShareX build with which to try out ownCloud support? :)

Jaex commented 9 years ago

@jancborchardt 3 days ago i was asked is anyone wants setup file in ownCloud IRC channel after see your request in here, i thought you were in channel.

Edit: Removed beta link because not necessary anymore.

jancborchardt commented 9 years ago

@Jaex awesome! :) Looking forward to the release of that.