archive/files/restore/{fileid} (POST)
Overview
Restores a deleted file back to its page
- REST Method: POST
- Method Access: public
Uri Parameters
Name | Type | Description |
fileid | int | identifies a file by ID |
Query Parameters
Name | Type | Description |
to | string? | Optional restore-to page to override a removed file's original parent id |
authenticate | bool? | Force authentication for request (default: false) |
Return Codes
Name | Value | Description |
OK | 200 | The request completed successfully |
Bad Request | 400 | Invalid input parameter or request body |
Forbidden | 403 | Administrator access is required |
Not Found | 404 | Requested file could not be found in the archive |
Implementation Notes
Use GET:archive/files to retrieve a list of files currently in the archive.
When a file is restored, it is moved from the file archive to the destination page. If the caller does not specify a destination page, the file is restored to its original page. A placeholder page will be created if the original page no longer exists.
C# Code Sample: Restore a File
The following code example restores 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("archive", "files", "restore", "456").With("to", "home").Post();
Curl Code Sample: Restore a File
This following command restores file with archive.fileID = 1 to its original page.
Sample Code
curl -u admin:password -H "Content-Type: text/plain" -d "" -i http://mindtouch.address/@api/deki/archive/files/restore/1
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. The quotations ("") are used to imply no data is to be sent.
- -H
- Replaces or appends an HTTP header. The "Content-Type" header specifies the MIME type of the value attached to the property. In this case, it does not really matter, but use text/plain as a precaution.
- -i
- Includes the HTTP response header in the output. Useful for debugging.
Permissions
- ADMIN permission is required to execute above command. Otherwise, a 403 HTTP response (Forbidden) will be returned.
Example
File with file.archive ID = 66 was accidently deleted and needs to be restored. The following command accomplishes that:
curl -u admin:password -H "Content-Type: text/plain" -d "" -i http://192.168.59.128/@api/deki/archive/files/restore/66
HTTP Response Headers
HTTP/1.1 200 OK Date: Tue, 19 Jan 2010 01:28:47 GMT Server: Dream-HTTPAPI/2.0.0.17629 Microsoft-HTTPAPI/2.0 Content-Length: 0 X-Data-Stats: request-time-ms=247; mysql-queries=15; mysql-time-ms=85; X-Deki-Site: id="default" Via: 1.1 dekiwiki Content-Type: text/plain
Notes
- To view the XML data of a list of all archived files, follow the path: /@api/deki/archive/files. For instance, the path for the above example would be http://192.168.59.128/@api/deki/archive/files.