Перейти к основному содержимому

Edit File API

POST /editFile

Description

This API endpoint allows an admin to edit the details of an existing file by providing the file's unique identifier and the updated details such as title, description, URL, and associated roles.

Request Body

The request utilizes GraphQL to perform the editFile mutation.

Mutation:

mutation editFile ($id: Int!, $file: FileEdit) {
editFile (id: $id, file: $file) {
id
title
description
url
}
}

Variables:

{
"id": 0,
"file": {
"title": "<File_Title>",
"description": "<File_Description>",
"url": "<File_URL>",
"roles": [
0
]
}
}
  • id (Int): The unique identifier of the file to be edited.
  • file (FileEdit Object): An object containing the updated details of the file.
    • title (String): The updated title of the file.
    • description (String): The updated description of the file.
    • url (String): The updated URL where the file is hosted or can be accessed.
    • roles (List of Int): A list of role IDs that are associated with this file.

Response:

  • Success (200 OK):

    • If the file update is successful, the response will return the updated details of the file, including its ID, title, description, and URL.
    {
    "data": {
    "editFile": {
    "id": "<File_ID>",
    "title": "<File_Title>",
    "description": "<File_Description>",
    "url": "<File_URL>"
    }
    }
    }
  • Error (4XX/5XX):

    • Appropriate error messages and status codes will be returned in cases of invalid file ID, missing required fields, or server errors.

Note:

Ensure that the id corresponds to an existing file within the platform and that the file object contains valid and correctly formatted data. This API should be used by admins with the necessary permissions to manage and update files linked to specific roles within the platform.