Skip to main content

Media Service

Media service will handle all the media-related services.

Endpoints

# Endpoints


Get S3 base url

This endpoint returns the environmental S3 base url.

Request

GET /media/base

Response (S3BaseResDTO)

{
"success": true,
"message": "",
"data": {
"s3Base": "https://jcci-test-media.aritaone.com/"
}
}

Upload media

This endpoint uploads media to a specific s3 key.

Request (UploadMediaReqDTO)

POST /media/upload

Key

Type

Value

files

file

-

fileKey

text

share/test

type

text

obj

access

text

public

temp

text

true

cacheControl

text

max-age=0

Response

{
"success": true,
"message": "",
"data": [
{
"fileKey": "temp/1234",
"url": "https://jcci-test.app-domain.com/temp/1234"
}
]
}

List media

This endpoint returns a list of keys under the specific folder.

Request (ListMediaReqDTO)

POST /media/list
{
"fileKey": "share/",
"delimiter": true
}

Response (ListMediaResDTO)

{
"success": true,
"message": "",
"data": [
{
"fileKey": "mhahk/lesson/cover/L001/1",
"updateTime": "2024-12-27T01:59:40.000Z"
},
{
"fileKey": "mhahk/lesson/cover/L001/2",
"updateTime": "2024-12-27T01:59:40.000Z"
}
]
}

List media size

This endpoint returns the number of media under the specific folder.

Request (ListMediaSizeReqDTO)

POST /media/list/size
{
"data": [
{
"tag": "123",
"fileKey": "share/",
"delimiter": true
}
]
}

Response (ListMediaSizeResDTO)

{
"success": true,
"message": "",
"data": [
{
"tag": "",
"size": 3
}
]
}

Delete media

This endpoint deletes the object.

Request (DeleteMediaReqDTO)

POST /media/delete
{
"fileKey": "share/",
"delimiter": true
}

Response

{
"success": true,
"message": "",
"data": null
}

Transfer media

This endpoint transfers the object from the temporary bucket to the practical bucket.

Request (TransferMediaReqDTO)

POST /media/transfer
{
"fileKeyFrom": "temp/folder/de506d6f-b398-4de0-9098-665845bad549",
"fileKeyTo": "test/123",
"sameBucket": false,
"cacheControl": "max-age=0"
}

Response

{
"success": true,
"message": "",
"data": null
}

Copy media

This endpoint copies the object from the temporary bucket to the practical bucket.

Request (TransferMediaReqDTO)

POST /media/copy
{
"fileKeyFrom": "temp/folder/de506d6f-b398-4de0-9098-665845bad549",
"fileKeyTo": "test/123",
"sameBucket": false,
"cacheControl": "max-age=0"
}

Response

{
"success": true,
"message": "",
"data": null
}

Check existence

This endpoint checks if a media exists or not. If the media exists, the response will return true success; otherwise, the response will return false success.

Request (CheckMediaReqDTO)

POST /media/existence
{
"fileKey": "share/data",
"defaultFileKey": "share/default/1"
}

Response (CheckMediaResDTO)

{
"success": true,
"message": "",
"data": {
"fileKey": "page/404",
"url": "https:/jcci-test-media.aritaone.com/page/404",
"modifiedTime": "2024-07-18T07:25:23.000Z"
}
}

To url

This endpoint converts fileKey to url. It only supports the assigned media only.

Request (ToUrlReqDTO)

POST /media/url
{
"fileKeys": [
{
"fileKey": "share/data"
}
]
}

Response (ToUrlResDTO)

{
"success": true,
"message": "",
"data": {
"fileKeys": [
{
"fileKey": "nlpra/article/blog/A009/image/0",
"url": "https://jcci-test-media.aritaone.com/nlpra/article/blog/A009/image/0"
}
]
}
}

Generate QR code

This endpoint generates a QR code

Request (QRReqDTO)

POST /qr
{
"url": "share/data",
"fileKey": "share/data"
}

Response

{
"success": true,
"message": "",
"data": null
}


Resources

S3BaseResDTO

properties
  • s3Base
    string
    required
    The S3 base url.

UploadMediaReqDTO

properties
  • files
    files
    A list of files for upload into AWS S3. If type = ''obj', only the first uploaded object will be uploaded to S3; if type = 'folder', all objects will be uploaded to the folder specific by the key.
  • fileKey
    string
    The S3 key for the file or folder.
  • type
    string
    default:  obj
    obj | folder
    The type of the upload nature. If 'obj', the key refers to the object; if 'folder', the key refers to the folder to hold the uploaded objects
  • access
    string
    default:  public
    public | private
    This indicates whether the uploaded files will have public-read access or not.
  • temp
    boolean
    default:  true
    true | false
    This indicates whether the uploaded files will be a temporary file or not.
  • cacheControl
    text
    default:  max-age=0
    This control the life time of the cache

ListMediaReqDTO

properties
  • fileKey
    string
    required
    The S3 folder key.
  • delimiter
    Boolean
    It indicates if the listed items include the sub-files. If true, it will not include the sub-files; otherwise, it will include all the sub-files

ListMediaResDTO

properties
  • fileKey
    string
    required
    File key
  • updateTime
    string
    required
    Updated time

ListMediaSizeReqDTO

properties
  • data
    ListMediaSizeItemReqDTO
    required
    The list of folders to check

ListMediaSizeItemReqDTO

properties
  • tag
    string
    required
    The field is reserved for customization.
  • fileKey
    string
    required
    The S3 folder key.
  • delimiter
    Boolean
    It indicates if the listed items include the sub-files. If true, it will not include the sub-files; otherwise, it will include all the sub-files

ListMediaSizeResDTO

properties
  • tag
    string
    The field is reserved for customization.
  • size
    number
    The number of files in the specific folder.

DeleteMediaReqDTO

properties
  • fileKey
    string
    required
    The S3 object key.
  • deleteMarker
    bool
    This is an optional field to indicate if the object needs to be permanently deleted or not.

TransferMediaReqDTO

properties
  • fileKeyFrom
    string
    required
    The S3 object key in the temporary bucket.
  • fileKeyTo
    string
    required
    The S3 object key in the practical bucket.
  • sameBucket
    boolean
    default:  false
    This indicates if the file is transferred from the temporary-file bucket or the application bucket. If false, it is transferred from the temporary-file bucket to the application bucket; if true, it is transferred within the application bucket.
  • cacheControl
    text
    default:  max-age=0
    This control the life time of the cache

CheckMediaReqDTO

properties
  • fileKey
    string
    required
    The S3 object key.
  • defaultFileKey
    string
    required
    The S3 object key for the default image.

CheckMediaResDTO

properties
  • fileKey
    string
    The S3 object key.
  • url
    string
    The URL path for the s3 object.
  • modifiedTime
    datetime
    The last modified time for the s3 object.

ToUrlReqDTO

properties
  • fileKeys
    FileDTO
    required
    A list of the S3 object key.

ToUrlResDTO

properties
  • fileKeys
    FileUrlDTO
    required
    A list of the S3 object key.

FileDTO

properties
  • fileKey
    string
    required
    The S3 object key.

FileUrlDTO

properties
  • fileKey
    string
    required
    The S3 object key.
  • url
    string
    required
    The url of the file.

QRReqDTO

properties
  • url
    string
    required
    The url path to be stored in the QR code.
  • fileKey
    string
    required
    The S3 object key.

UploadResDTO

properties
  • fileKey
    string
    The S3 key for the file or folder.
  • url
    string
    The url path of the uploaded files.


Folder Structure

Tree Structure

.
├── mhahk
│   ├── article
│   │   ├── ap
│   │   │   ├── kl
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   └── nt
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   ├── as
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   ├── ls
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   └── mh
│   │   └── {articleId}
│   │   ├── audio
│   │   │   └── 1
│   │   ├── pdf
│   │   │   └── 1
│   │   ├── photo
│   │   │   └── {...}
│   │   ├── thumbnail
│   │   │   └── 1
│   │   └── video
│   │   └── 1
│   ├── community
│   │   └── info
│   │   ├── cko&sk
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── kc
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── kt
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── st&mos
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── tp&n
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   └── wts
│   │   └── {communityInfoId}
│   │   └── 1
│   └── user
│   └── {userId}
│   ├── community
│   │   └── map
│   │   ├── cko&sk
│   │   │   └── 1
│   │   ├── kc
│   │   │   └── 1
│   │   ├── kt
│   │   │   └── 1
│   │   ├── ssp
│   │   │   └── 1
│   │   ├── st&mos
│   │   │   └── 1
│   │   ├── tc
│   │   │   └── 1
│   │   ├── tm
│   │   │   └── 1
│   │   ├── tp&n
│   │   │   └── 1
│   │   ├── tsw
│   │   │   └── 1
│   │   ├── twkt
│   │   │   └── 1
│   │   ├── wts
│   │   │   └── 1
│   │   ├── yl
│   │   │   └── 1
│   │   └── ytm
│   │   └── 1
│   └── profile
│   └── 1
├── nlpra
│   ├── article
│   │   ├── ap
│   │   │   ├── is
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   ├── kc
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   ├── ssp
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   ├── tm
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   ├── tsw
│   │   │   │   └── {articleId}
│   │   │   │   ├── audio
│   │   │   │   │   └── 1
│   │   │   │   ├── pdf
│   │   │   │   │   └── 1
│   │   │   │   ├── photo
│   │   │   │   │   └── {...}
│   │   │   │   ├── thumbnail
│   │   │   │   │   └── 1
│   │   │   │   └── video
│   │   │   │   └── 1
│   │   │   └── ytm
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   ├── as
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   ├── ls
│   │   │   └── {articleId}
│   │   │   ├── audio
│   │   │   │   └── 1
│   │   │   ├── pdf
│   │   │   │   └── 1
│   │   │   ├── photo
│   │   │   │   └── {...}
│   │   │   ├── thumbnail
│   │   │   │   └── 1
│   │   │   └── video
│   │   │   └── 1
│   │   └── mh
│   │   └── {articleId}
│   │   ├── audio
│   │   │   └── 1
│   │   ├── pdf
│   │   │   └── 1
│   │   ├── photo
│   │   │   └── {...}
│   │   ├── thumbnail
│   │   │   └── 1
│   │   └── video
│   │   └── 1
│   ├── community
│   │   └── info
│   │   ├── ssp
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── tc
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── tm
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── tsw
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── twkt
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   ├── yl
│   │   │   └── {communityInfoId}
│   │   │   └── 1
│   │   └── ytm
│   │   └── {communityInfoId}
│   │   └── 1
│   └── user
│   └── {userId}
│   ├── community
│   │   └── map
│   │   ├── cko&sk
│   │   │   └── 1
│   │   ├── kc
│   │   │   └── 1
│   │   ├── kt
│   │   │   └── 1
│   │   ├── ssp
│   │   │   └── 1
│   │   ├── st&mos
│   │   │   └── 1
│   │   ├── tc
│   │   │   └── 1
│   │   ├── tm
│   │   │   └── 1
│   │   ├── tp&n
│   │   │   └── 1
│   │   ├── tsw
│   │   │   └── 1
│   │   ├── twkt
│   │   │   └── 1
│   │   ├── wts
│   │   │   └── 1
│   │   ├── yl
│   │   │   └── 1
│   │   └── ytm
│   │   └── 1
│   └── profile
│   └── 1
└── share
├── default
│   ├── article
│   │   └── 1
│   ├── community
│   │   ├── info
│   │   │   └── 1
│   │   └── map
│   │   └── 1
│   └── user
│   └── profile
│   ├── 1
│   ├── 2
│   ├── 3
│   └── 4
└── user
└── {userId}
├── community
│   └── map
│   ├── cko&sk
│   │   └── 1
│   ├── kc
│   │   └── 1
│   ├── kt
│   │   └── 1
│   ├── ssp
│   │   └── 1
│   ├── st&mos
│   │   └── 1
│   ├── tc
│   │   └── 1
│   ├── tm
│   │   └── 1
│   ├── tp&n
│   │   └── 1
│   ├── tsw
│   │   └── 1
│   ├── twkt
│   │   └── 1
│   ├── wts
│   │   └── 1
│   ├── yl
│   │   └── 1
│   └── ytm
│   └── 1
└── profile
└── 1

Naming

article: 精神健康資訊

ap: 活動推廣

mh: 認識精神健康資訊

ls: 生命故事分享

as: 專欄分享

「活動推廣」 分類

kl: 九龍

nt: 新界

is: 離島安泰軒

kc: 葵涌安泰軒

ssp: 深水埗安泰軒

tm: 屯門安泰軒

tsw: 天水圍安泰軒

ytm: 油尖旺安泰軒

community-info (MHAHK): 地區資訊

cko&sk: 將軍澳/西貢

kc: 九龍城

kt: 觀塘

st&mos: 沙田/馬鞍山

tp&n: 大埔/北區

wts: 黃大仙

community-info (NLPRA): 地區資訊

ssp: 深水埗

tc: 東涌

tm: 屯門

tsw: 天水圍

tmkt: 荃葵青

yl: 元朗

ytm: 油尖旺