Skip to content

Portal Apis

The documentation applies to:✅ v0.8.0

Default appsettings.json

Beacuse Portal APIs is a core api so that we will group some options following features

Database Options

{
    "DatabaseOptions": {
        "ConnectionString": "mongodb://localhost:27017", // Identity Database Connection string
        "DataSource": "letportal", // Database name
        "ConnectionType": "MongoDB" // MongoDB or SQLServer or PostgreSQL or MySQL
    }
}

MongoOptions and MapperOptions

{
    // Allow to remove double quotes while transforming to Bson
    "MongoOptions": {        
        "AllowedFunctions": [ "ObjectId", "ISODate", "NumberLong" ] 
    },
    // Define mapping between C# data type and SQL data type
    "MapperOptions": {
        "MySQL": {
            "decimal": "Decimal",
            "double": "Double",
            "float": "Float",
            "timespan": "Int64",
            "long": "Int64",
            "int": "Int32",
            "bool": "Bit",
            "date": "Datetime",
            "string": "LongText"
        },
        "PostgreSQL": {
            "decimal": "Money",
            "double": "Double",
            "float": "Double",
            "timespan": "Bigint",
            "long": "Bigint",
            "int": "Integer",
            "bool": "Boolean",
            "date": "Date",
            "string": "Text"
        },
        "SQLServer": {
            "decimal": "Decimal",
            "double": "Float",
            "float": "Float",
            "timespan": "BigInt",
            "long": "BigInt",
            "int": "Int",
            "bool": "Bit",
            "date": "DateTime",
            "string": "NVarChar"
        }        
    }
}

File Options

FileOptions is helping you to configure File APIs. We are only supporting DiskStorage and Database Storage, another storage can be extended out-of-the-box

{ 
    "FileOptions": {
        "FileStorageType": "Database", // Database or Disk
        "DownloadableHost": "http://localhost:53595/v1.0/files", // A public endpoint of File APIs, which can access from a client
        "DiskStorageOptions": {     
            "AllowDayFolder": true, // Create sub folder with name is 'yyyyMMdd'
            "Path": "~/UploadFiles" // Path of folder
        }
    },
    "DatabaseStorageOptions": {
        "SameAsPortal": true, // true if the connection is the same with Portal Database
        // If SameAsPortal is false, use the connection below
        "DatabaseOptions": {
            "ConnectionString": "mongodb://localhost:27017", // Database Connection string
            "DataSource": "uploaddb", // Database name
            "ConnectionType": "MongoDB" // MongoDB or SQLServer or PostgreSQL or MySQL
        }
    },
    "FileValidatorOptions": {
        "MaximumFileSize": 16777216, // Maximum Upload File size, in bytes, Default is 16MB
        "CheckFileExtension": true, // Check upload file ext on WhiteLists
        "WhiteLists": "jpg;jpeg;gif;png;json;zip;",
        // Check upload file magic number
        "ExtensionMagicNumbers": {
            "jpg": "FF-D8",
            "jpeg": "FF-D8",
            "gif": "47-79-46-38",
            "bmp": "42-4D",
            "tif": "49-49",
            "png": "89-50-4E-47",
            "ico": "00-00-01-00",
            "mp3": "49-44-33",
            "avi": "52-49-46-46",
            "mp4": "00-00-00-18-66-74-79-70-6D-70-34-32",
            "zip": "50-4B-03-04",
            "gz": "1F-8B-08",
            "tar": "75-73-74-61-72",
            "dll": "4D-5A",
            "exe": "4D-5A",
            "pdf": "25-50-44-46",
            "doc": "D0-CF-11-E0-A1-B1-1A-E1",
            "rtf": "7B-5C-72-74-66-31",
            "xls": "D0-CF-11-E0-A1-B1-1A-E1",
            "ppt": "D0-CF-11-E0-A1-B1-1A-E1",
            "docx": "50-4B-03-04",
            "xlsx": "50-4B-03-04",
            "pptx": "50-4B-03-04",
            "txt": "",
            "json": ""
        }
    }
  }
}

Backup Options

{
    "BackupOptions": {
        "BackupFolderPath": "Backups", // Folder for creating backup package
        "RestoreFolderPath": "Restores", // Folder for uploading backup package 
        "MaximumObjects": 100 // Number of backup objects, default is 100, very important to memory leak
    }
}