Skip to main content

Files (assets)

Upload PDF · PPTX documents and PNG · JPEG · WebP · GIF images on the settings screen, and read their URLs from any screen. Videos are not uploaded here (Video player).

No personal information

Do not upload files containing learners' personal information (face photos · ID cards · rosters, etc.). The uploaded file id is saved in settings, and settings is sent to every viewer, including students.

// 설정 화면: 올리고 id를 settings에 저장
const controller = new AbortController();
const asset = await sdk.assets.post(input.files[0], {
onProgress: ({ loaded, total }) => (bar.value = loaded / total),
signal: controller.signal, // controller.abort()로 취소
});
await sdk.saveSettings({ ...sdk.material.settings, file: asset.id });

// 학습 화면: id로 서명된 주소 읽기
const file = await sdk.assets.get(sdk.material.settings.file);
if (file) viewer.src = file.url;

Uploading (post)​

post(file, { onProgress?, signal? }) returns { id, name, size, mime, url }.

  • It works only on the settings screen opened with an edit token. Other screens get screen_not_supported, and the settings screen of an unsaved upload (#edit=1) gets draft_not_saved.
  • The type is determined by the file's MIME type, or by its extension if there is none.
TypeMIME · extensionMax size
PDFapplication/pdf, .pdf95MB
PPTX.pptx95MB
PNGimage/png, .png10MB
JPEGimage/jpeg, .jpg · .jpeg10MB
WebPimage/webp, .webp10MB
GIFimage/gif, .gif10MB
  • Any other file, including SVG, is file_invalid_type.
  • Files of 0 bytes or over the limit are rejected with file_invalid_size before asking the server.
  • Images are uploaded as is. To shrink them or remove metadata (EXIF · GPS), process them yourself before uploading.
  • Files are sent in blocks of up to 50MB. onProgress is called each time a block is sent, and again with loaded === total when the upload finishes. For files smaller than 50MB it is called only at the end.
  • When cancelled, post fails with the signal's reason (AbortError). There is no delete feature yet.

Reading (get)​

get(id) returns { id, url } or null.

  • It returns null before init(), when the screen's version has no signed URL, or when the id is not a file id of this material.
  • It does not return the name, size, or format. If you need them, save the values you received at upload time in settings as well.
Save the id, not the url

id is the storage key decided by the server (in the form assets/{material_id}/{asset_id}.pdf; images use their own extension). url expires like the screen URL, so save id in settings and get a URL with get(id) each time you display the file.