splitbrain / ReMarkableAPI

Docs and implementation of the reMarkable file sync API
https://www.splitbrain.org/blog/2018-02/02_file_sync_for_remarkable_tablet
MIT License
374 stars 27 forks source link

"Corrupt" files when uploading #5

Closed ericsfraga closed 6 years ago

ericsfraga commented 6 years ago

If I try to upload a PDF document, the PHP script seems to do the job but the tablet claims the document is corrupt when it downloads from the cloud. The "list" however seems to show that the documents are stored in the cloud (although if no "to" was given on the upload, they are placed in a separate folder named with the UUID of the document). Happy to provide more details if desired.

Downloading (which is my main use case for your code) works very well indeed. Thank you!

tfawcett commented 6 years ago

FWIW, I have the same problem with corrupted uploads. I haven't managed to upload a PDF successfully. I'm using Mac OS X 10.13.3.

splitbrain commented 6 years ago

hmm... weird. I thought I had it working. I have to experiment a bit more...

ericsfraga commented 6 years ago

Let me know if there's anything you want me to try. I've had a look at the cloud storage via the reMarkable app on an Android device and the actual PDF documents each appear as single blank pages within folders named with the UUID. The originals were definitely not single blank pages.

splitbrain commented 6 years ago

Okay, I'm an idiot. I had looked a the network stream and mistook a zip header for a PDF header...

The upload API uses the same file format as the downloads (which totally makes sense for a sync API). So there is no upload of raw PDF data, but PDFs wrapped in a zip file with additional metadata.

I just pushed a very rough fix that will wrap the given PDF file. It worked in my tests with the android client. My tablet is at the office so I can't look if it really works. I had to omit a bit of the meta data and the thumbnails, but at least the Android client seems to regenerate those automatically. I how the tablet does, too.

Could you check if the latest version works for you? (be sure to do a composer install again).

(I also fixed the problem with uploading to the root namespace)

ericsfraga commented 6 years ago

Just did a quick test and it seems to work just fine now. Many thanks!