FileList

From Tomes Support Wiki

Jump to: navigation, search

Contents

FileList

FileList provides a paged list of files and directories contained beneath the requested path. Paging size should be 50 items per page. The client will make subsequent requests when it's ready for more.

Request

The request includes the protocol version "sv" parameters, the path parameters "p", with HexEncoding, and the page number paramter "pg", and an optional filter string "f" which causes only matching files and folders to be returned.

Note that filter support is NOT currently implemented in the Tomes GUI, but servers should support it for future enhancement. Filters should also be encoded with HexEncoding.

http://127.0.0.1:8080/FileList?sv=0100&p=2f53616d706c6544617461&pg=0

The client may pass a page of -1 which means all items should be returned. The client uses this functionality to perform a recursive download.

Response

XML like the following:

  1.  
  2. <response xmlns:dc="http://purl.org/dc/elements/1.1/">
  3. <action>/FileList</action> <!-- echo'd back -->
  4. <status>200</status><!-- 200 ok, 404 not found, 403 denied, 500 server error -->
  5. <path>/SampleData</path> <!-- echo'd back -->
  6. <supports-filter>true</supports-filter> <!-- Indicates that the f (filter) parameter is supported in this location. False is assumed if tag is absent. -->
  7. <filter/> <!-- filter echo'd back or empty tag -->
  8. <count>17</count> <!-- Number of files, directories and links included. -->
  9. <page>0</page> <!-- current page number (zero-based) -->
  10. <lastpage>0</lastpage> <!-- final page number (zero-based) -->
  11. <recursivedl>true</recursivedl> <!-- true if the client should show the recursive download action -->
  12. <summary>Short summary of directory's contents, text only</summary>
  13. <files><!-- contains one or more files, directories, or server links. Will be sorted by name on the client. -->
  14. <file><!-- A file element -->
  15. <idx>0</idx> <!-- ever increasing index number for all items in this response -->
  16. <name>Color_test.pdb</name> <!-- name of the file -->
  17. <size>321</size> <!-- size in bytes -->
  18. <info/><!-- Indicates an info (readme) file. See Info section below for details -->
  19. <storagepath>local/path/to</storagepath> <!-- Optional path where book will be stored on device (uses location in shelf server tree if not set). Must not contain filename, must not start with or end with a slash, must not contain the string "..". If invalid, file will be silently downloaded as if storagepath wasn't set. -->
  20. <dc:title>human readable title</dc:title>
  21. <dc:author>...</dc:author>
  22. <dc:identifier>http://.../book.html</dc:identifier><!-- link to web page for this book -->
  23. <dc:language>en</dc:language><!-- Two-letter ISO code -->
  24. <dc:date>2009</dc:date><!-- Publication year -->
  25. <dc:description>...</dc:description> <!-- summary of book - may use HTML P or BR tags for new lines. No other HTML currently supported. -->
  26. <dc:rights>...</dc:rights><!-- Either standard copyright statement or CC or similar license grant. -->
  27. <cover>http://..../pic.png</cover><!-- Larger cover image (screen sized) -->
  28. <thumb>http://..../pic.png</thumb><!-- Tiny (less than 100x100px) pixel image for thumbnail -->
  29. <rating>4</rating><!-- 0..5 -->
  30. <purchase-status>FREE</purchase-status><!-- One of FREE, PAID, BUYNOW -->
  31. <purchase-price>US$0.00</purchase-price><!-- Purchase price as string, including currency indicator. -->
  32. <purchase-url>http://example.com/buy/42</purchase-url><!-- URL to hit to trigger sale. User's credentials will be appended. -->
  33. </file>
  34. <dir><!-- a directory component -->
  35. <idx>1</idx>
  36. <name>LittleBrotherHTML</name>
  37. <!-- Directories may optionally contain title, author, etc., up though thumb from above. -->
  38. </dir>
  39. </files>
  40. <link><!-- link to an external shelf server -->
  41. <idx>2</idx>
  42. <name>Human readable name</name>
  43. <url>http://example.com/ShelfServer/</url> <!-- Base URL (where ShelfName.xml is) -->
  44. <summary>text-only description of what the shelf contains</summary>
  45. </link>
  46. </response>
  47.  

Notes:

So to use easy numbers.... If you had 35 items and 10 items per page, count=35 and lastpage=3. The phone would pass pg=0..3 to you, 0..2 would give ten items each, 3 would give the last five.

The client on the phone assumes you told it the truth as far as lastpage based on the number of items you're sending on each page. With each subsequent request, the phone appends the list it got onto an array. If you lie and give it less than a full page's worth on another other than the last page, it should technically still work, but the counts on the button at the bottom will probably get screwy.

Info Files

Recent versions of ShelfServer support a file extension of ".info" used to identify a plain-text file which should be presented as a type of "readme" directly within the shelf interface. For these files, the entire contents of the file (keep it short!) is included within the dc:description tag, and the file is reported as if it was a plain-text file. The info tag itself is an empty marker tag only.

Tomes clients which interpret this tag will present the file in a distinct format from normal books. Tapping either the table row OR the details disclosure icon for these books will display the book details screen, where the full text of the file is available to be read without downloading.

Cover & Thumb Art

Artwork images may be specified either as full literal URLs or as filenames. If a filename is found, it will be retrieved by calling the FileSend endpoint passing the filename from this XML appended as a path onto the folder containing the listing. Relative paths are not allowed as they could lead to path injection.

For example, if the book at /books/novels/WarAndPeace.txt has a cover attribute of W+P.jpg, the client will request /books/novels/W+P.jpg from the server.

Commerce

(Note that purchase support is not yet implemented in Issues for v1.4 . It's not yet certain whether it will be ready for Issues for v1.4

or wait for Issues for v1.5

.

The protocol supports passing basic commerce related information for on-device sales. No provision is made for transferring payment information. It is presumed the user has previously established an account through other means and that purchases will be charged to that account.

Three fields are provided for purchase related data.

purchase-status indicates the status of the item. Possible options are:

purchase-price indicates the amount that will be charged for this item if purchased. The amount is a free-text string, but it must contain the amount and an indication of the currency in which the amount will be charged. This field is ignored if purchase-status is FREE or PAID.

purchase-url is the HTTP URL which will be accessed to complete a purchase of the item. The request will have the user's username and password appended as usual for ShelfServer URL's. The server response must be XML in the form of:

  1.  
  2. <response>
  3. <status>200</status><!-- 200 for success, 5xx for failure. -->
  4. <message>Thanks!</message><!-- A short thank you or error message. -->
  5. </response>
  6.  

After purchase success or failure, the given message will be displayed to the user. For success, the download URL as calculated from the original FileList request will be used to retrieve the purchased content. On failure, the FileList request will be refreshed to retrieve updated information.

As the download URL for purchased content is available to all users before purchase, it is the server's responsibility to deny downloads to purchased content which has not been purchased by the account given in the URL query string.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox