files/{fileid}/move (POST)
Overview
Move an attachment from one page to another and/or change the filename
- REST Method: POST
- Method Access: public
Uri Parameters
Name | Type | Description |
fileid | int | identifies a file by ID |
Query Parameters
Name | Type | Description |
authenticate | bool? | Force authentication for request (default: false) |
name | string? | new filename |
to | string? | page id of target page |
Return Codes
Name | Value | Description |
OK | 200 | The request completed successfully |
Bad Request | 400 | Invalid input parameter or request body |
Forbidden | 403 | Update access to the page is required |
Not Found | 404 | Requested file could not be found |
Implementation Notes
A file cannot be moved to a template page or a destination page that already contains a file with the same name.
C# Code Sample: Move a File
The following code example moves the file with ID 456 to the home page:
Sample Code
Plug p = Plug.New("http://deki-hayes/@api/deki"); p.At("users", "authenticate").WithCredentials("admin", "password").Get(); p.At("files", "456", "move").With("to", "home").Post();
Curl Code Sample: Move a File
The following command moves a file to a specified page. Both target file ID and destination page ID must be specified. In the following sample, a file with file ID "1" is moved to the page with page ID "2".
Sample Code
curl -u username:password -d "" -i http://mindtouch.address/@api/deki/files/1/move?to=2
Implementation notes
curl flags
- -u
- Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
- -d
- Specifies a POST request. No data needs to be sent to process this request, so an empty string is sent ("").
- -i
- Includes the HTTP response header in the output. Useful for debugging.
Example
An image of a popular meme needs to be moved to the Meme page (page ID = 68). The image has an ID value of 3.
Sample Code
curl -u username:password -d "" -i http://192.168.168.110/@api/deki/files/3/move?to=68
HTTP Response Headers
HTTP/1.1 200 OK Date: Mon, 11 Jan 2010 22:40:35 GMT Server: Dream-HTTPAPI/1.7.2.17433 X-Deki-Site: id="default" Content-Length: 0 Via: 1.1 dekiwiki Content-Type: text/plain