User Tools

Site Tools


api:file:create

API : File Create

Introduction

Upload a new file or folder, including metadata settings.

To the request should be a multipart form if it's a file being uploaded, and a request with a JSON body if it's a folder.

Request

URL https://api.telecomx.dk/file
Method POST - with a JSON body for folder creation
POST - with multipart/form-data for uploading a file
Access level MANAGER, OWNER - create on customer self
RESELLER, RESELLER_ADMIN or ADMIN - create on specified customer, defaults to own customer.
Body file Attached file, not used if type is FOLDER
filename Filename of the uploaded file, allows the user to give the file a better display name.
accessLevel Determines who can access the document. ALL, CUSTOMER, EMPLOYEE, RESELLER.
description Optional description of file.
type Type of file. Only used when creating a folder, then type should be FOLDER.
customer Optional Id of customer to create on (only applies to RESELLER, RESELLER_ADMIN and ADMIN).

Query example

https://api.telecomx.dk/file

Response

The response will be the newly created document, if no errors occurred.

Property Type Description
_id ObjectID Id
filename String Filename
fileId ObjectID Id used to reference to file on file server
size Integer Size of the file in bytes
filetype String Filetype: png, jpg, gif, xls, xlsx, doc, docx, pdf, ppt, pptx, txt, csv
folder ObjectId Reference to the folder which contains this file
employee ObjectID Id of employee who added the file
customer ObjectID Id of the customer the file was added to
type String Type of file: PORTING, INTERNET, AUDIO, IMAGE, DOC, FOLDER, OTHER
width Integer If image, then this is the width in pixels
height Integer If image, then this is the height in pixels
description String Optional description for the file, e.g. 'Porting of 81808888'
date ISODate Date and time when the file was added
lastUpdated ISODate Date and time when the file was last updated/edited
accessLevel Enum Determines who can access the file. ALL, CUSTOMER, EMPLOYEE, RESELLER
{
    _id: '1234567890ABCDEF12345678',
    filename: 'Power of attorney 23072014.pdf',
    size: 35465,
    filetype: 'pdf',
    employee: 1234567890ABCDEF12345678,
    customer: 1234567890ABCDEF12345678,
    type: 'PORTING',
    width: null,
    height: null,
    description: 'Porting of 12345678',
    date: ISODate('2014-01-01T12:34:56.123Z'),
    accessLevel: 'EMPLOYEE'
}

Errors

Error code Message Description
403 access_denied Insufficient access level
404 file File not found in body of request
409 folder Folder and parent folder don't belong to the same customer
422 filename The chosen file name does not have the same extension as the uploaded file
422 storage There is not enough available storage to upload this file
422 filesize Filesize exceeds maximum filesize of 10 mb
422 file Invalid <type> file
422 accessLevel A personal file can not be created on a reseller's customer
500 file <Unspecified>
api/file/create.txt · Last modified: 2025/04/23 07:38 by Per Møller

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki