contents

Save or upload file.

Changed on

Saves the file in the location specified by name and path. PUT is very similar to POST, but the requester specifies the name, whereas with POST, the server picks the name.

put/api/contents/{path}

Request

  • Base URL
    / (relative, and the document was published on a file host, not at the API’s origin)
  • Auth
    none declared

Path parameters

path, string required

file path

Request body

object required
name, string

The new filename if changed

path, string

New path for file or directory

type, string

Path dtype ('notebook', 'file', 'directory')

format, string

File format ('json', 'text', 'base64')

content, string

The actual body of the document excluding directory type

chunk, integer

1-based index of the chunk when uploading a file in parts, or -1 for the last chunk. Chunk 1 creates or truncates the file; later chunks append to it.

Response

File saved

Contents required

A contents object. The content and format keys may be null if content is not contained. The hash maybe null if hash is not required. If type is 'file', then the mimetype will be null.

name, string required

Name of file or directory, equivalent to the last part of the path

path, string required

Full path for file or directory

type, 'directory' | 'file' | 'notebook' required

Type of content

writable, boolean required

indicates whether the requester has permission to edit the file

created, string dateTime required

Creation timestamp

last_modified, string dateTime required

Last modified timestamp

size, integer

The size of the file or notebook in bytes. If no size is provided, defaults to null.

mimetype, string required

The mimetype of a file. If content is not null, and type is 'file', this will contain the mimetype of the file, otherwise this will be null.

content, union

The content, if requested (otherwise null). Will be an array if type is 'directory'

format, string required

Format of content (one of null, 'text', 'base64', 'json')

hash, string

[optional] The hexdigest hash string of content, if requested (otherwise null). It cannot be null if hash_algorithm is defined.

hash_algorithm, string

[optional] The algorithm used to produce the hash, if requested (otherwise null). It cannot be null if hash is defined.

Changes