Uploading Files

Deprecation Notice

This API is deprecated as of July 19, 2011. Users are strongly encouraged to upgrade to the more powerful file management APIs.

The new file management APIs have several benefits, including:

  • File transfers no longer require first requesting an upload token.
  • Support for downloading a file via the API (whether uploaded directly or generated via a PDF conversion).
  • File listing capabilities with filtering and pagination.
  • Adherence to our standard API conventions, including support for both XML and JSON.

Uploading Files

The legacy upload action involves two steps: requesting an upload token, then supplying that token to performing an upload.

Request Upload Token

This API does not adhere to our standard API conventions.

Purpose

Before any files can be uploaded for use in later API calls, you must request and receive an upload token. The result is a single-use token which can be used to upload one file for use in later publishing calls.

POST Arguments

  • api_key -- Your api key for the Publish API.
  • auth_user -- The Lulu.com account you used with the authenticator API to login for this session.
  • auth_token -- The auth token returned from the authenticator API.

Endpoint

https://apps.lulu.com/api/publish/v1/request_upload_token

JSON Response

{ 'token': 'abcdefg1234567' }

Upload

This API does not adhere to our standard API conventions.

Purpose

The first step to creating a new project is to upload all of the files that will be used in creating your project. This usually consists of the contents of the book (also known as the book block) and the cover for the book. These must have different names, or one will overwrite the other. All files that are uploaded and not used in projects will be deleted 21 days after they are uploaded. Files that are uploaded through this API are not available in the Lulu website. This is a limitation that we are working to resolve.

Uploading files is a two-step process, first you must request an upload token, then you can upload the file. Please note, that the upload request is sent to a totally different URL.

POST Arguments

  • upload_token -- The token retrieved from the request upload token request.
  • auth_user -- The Lulu.com account you used with the authenticator API to login for this session.
  • auth_token -- The auth token returned from the authenticator API.
  • file data -- The file to upload

These arguments are all uploaded using a multipart mime request.

Endpoint

This is a different hostname from all other APIs. If you attempt to upload using the https://apps.lulu.com/ hostname, the request will fail.

https://pubapp.lulu.com/api/publish/v1/upload

JSON Response

{
    "written_files": [
        "85x11_120p.pdf",
        "85x11_120p_hardcover.pdf"
    ],
    "uploaded": [
        { "file_id": 828, "filename": "85x11_120p.pdf" },
        { "file_id": 829, "filename": "85x11_120p_hardcover.pdf" }
    ]
}

In the "uploaded" field, the upload response contains the list of uploaded files. The file identifier ("file_id") is a reference into the file management APIs and is the preferred means of accessing the file.  The file ID can be used as an input into document conversion as well as project creation.