tvpl.api

<back to all web services

FileUpload

Upload file

Requires Authentication
The following routes are available for this service:
POST/uploadTải file
import 'package:servicestack/servicestack.dart';

abstract class IHttpFile
{
    String? name;
    String? fileName;
    int? contentLength;
    String? contentType;
    Uint8List? inputStream;
}

enum AccessType
{
    Public,
    Restricted,
}

enum StorageStatus
{
    Draft,
    Permanent,
    Archive,
}

class FileUploadRequest implements IConvertible
{
    IHttpFile? fileUpload;
    AccessType? accessType;
    StorageStatus? storageStatus;

    FileUploadRequest({this.fileUpload,this.accessType,this.storageStatus});
    FileUploadRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        fileUpload = JsonConverters.fromJson(json['fileUpload'],'IHttpFile',context!);
        accessType = JsonConverters.fromJson(json['accessType'],'AccessType',context!);
        storageStatus = JsonConverters.fromJson(json['storageStatus'],'StorageStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'fileUpload': JsonConverters.toJson(fileUpload,'IHttpFile',context!),
        'accessType': JsonConverters.toJson(accessType,'AccessType',context!),
        'storageStatus': JsonConverters.toJson(storageStatus,'StorageStatus',context!)
    };

    getTypeName() => "FileUploadRequest";
    TypeContext? context = _ctx;
}

abstract class IResponseRequest
{
    int? code;
    String? message;
}

/**
* Upload file
*/
class FileUpload extends FileUploadRequest implements IPost, IConvertible
{
    FileUpload();
    FileUpload.fromJson(Map<String, dynamic> json) : super.fromJson(json);
    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson();
    getTypeName() => "FileUpload";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'etc_api.vsmlab.vn', types: <String, TypeInfo> {
    'IHttpFile': TypeInfo(TypeOf.Interface),
    'AccessType': TypeInfo(TypeOf.Enum, enumValues:AccessType.values),
    'StorageStatus': TypeInfo(TypeOf.Enum, enumValues:StorageStatus.values),
    'FileUploadRequest': TypeInfo(TypeOf.Class, create:() => FileUploadRequest()),
    'IResponseRequest': TypeInfo(TypeOf.Interface),
    'FileUpload': TypeInfo(TypeOf.Class, create:() => FileUpload()),
});

Dart FileUpload DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

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/csv
Content-Type: text/csv
Content-Length: length

{"fileUpload":null,"accessType":"Public","storageStatus":"Draft"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{Unable to show example output for type 'IResponseRequest' using the custom 'csv' filter}Cannot dynamically create an instance of type 'tvpl.api.ServiceModel.IResponseRequest'. Reason: Cannot create an instance of an interface.