| POST | /upload | Tải file |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class IHttpFile:
name: Optional[str] = None
file_name: Optional[str] = None
content_length: int = 0
content_type: Optional[str] = None
input_stream: Optional[bytes] = None
class AccessType(str, Enum):
PUBLIC = 'Public'
RESTRICTED = 'Restricted'
class StorageStatus(str, Enum):
DRAFT = 'Draft'
PERMANENT = 'Permanent'
ARCHIVE = 'Archive'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FileUploadRequest:
file_upload: Optional[IHttpFile] = None
access_type: Optional[AccessType] = None
storage_status: Optional[StorageStatus] = None
class IResponseRequest:
code: int = 0
message: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FileUpload(FileUploadRequest, IPost):
"""
Upload file
"""
pass
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /upload HTTP/1.1
Host: etc-api.vsmlab.vn
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"fileUpload":null,"accessType":"Public","storageStatus":"Draft"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{Unable to show example output for type 'IResponseRequest' using the custom 'other' filter}Cannot dynamically create an instance of type 'tvpl.api.ServiceModel.IResponseRequest'. Reason: Cannot create an instance of an interface.