• Create an attachment

    Parameters

    • ownerId: string

      unique identifier of the owner

    • ownerType: string

      type of the owner

    • attachmentService: AttachmentService

      injected service use to handle the attachment related operations

      • createAttachment
      • getOneAttachment
      • normalizeAttachment
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query]. Note:

      • body is required

    Returns Promise<AdapterHandlerResponse>

    201 Status Created

    Description

    This handler is used to create an attachment by applying the following steps in sequence:

    1. Check if request body exists

    2. Create the attachment (attachmentService.createAttachment)

    3. Get the created attachment (attachmentService.getOneAttachment)

    4. Normalize the attachment (attachmentService.normalizeAttachment)

    5. Return the normalized attachment

    Throws

    Error

    • no body in context

    Throws

    500 NBError Internal Server Error

    • error creating attachment

    Example: example data response

    {
    "id": "1",
    "ownerId": "userId",
    "ownerType": "user",
    "name": "image.png",
    "type": "image/png",
    "isPublic": true,
    "url": "https://api.example.com/attachments/objectId",
    }

Generated using TypeDoc