Commands: Delete
The DELETE methods allow to remove a single file or multiple files at once from the file system.
Single file deletion
Syntax
curl \
http://{serverUrl}/fs/{fileSystemName}/files/{name} \
-X DELETE \
--header "If-None-Match:{etag}"
Request
Query parameter | Required | Description |
---|---|---|
name | Yes | The name of a file to be deleted |
Header | Required | Description |
---|---|---|
If-None-Match | No | Used to pass the file Etag |
Response
Status code | Description |
---|---|
204 |
No Content status means that the file has been deleted successfully |
405 |
The concurrency exception occurred |
420 |
The synchronization exception occurred |
Return Value | Description |
---|---|
None | The request does not return any message |
Example
curl -X DELETE http://localhost:8080/fs/NorthwindFS/files/movies/intro.avi
< HTTP/1.1 204 No Content
Multiple files deletion
In order to delete multiple files you need to send the DELETE request to the search endpoint that specifies a query. All files matching that query will be deleted. The actual delete operation is implemented as the background operation which identifier is returned in the response. Later you use it to ask about the delete operation status.
Syntax
curl \
http://{serverUrl}/fs/{fileSystemName}/search?query={query} \
-X DELETE
Request
Query parameter | Required | Description |
---|---|---|
query | Yes | The Lucene query used to find files to delete |
Response
Status code | Description |
---|---|
200 |
OK means that delete by query operation has been scheduled |
Return Value | Description |
---|---|
OperationId | The identifier of the background delete by query operation |
Example
In order to start delete operation of all files located in the /temp
folder and its subdirectories, run the following command:
curl -X DELETE http://localhost:8080/fs/NorthwindFS/search?query=__directoryName:/temp
< HTTP/1.1 200 OK
{
"OperationId":1
}
Check the operation status by using the following endpoint:
curl -X GET http://localhost:8080/fs/NorthwindFS/operation/status
You will either get OK
response with a state message or NotFound
if the task completed successfully and was deleted.