Chuyển tới nội dung chính

Tải lên tệp giấy tờ

Được sử dụng để tải lên tệp giấy tờ và lấy fileId. Đây là bước 1 trong quy trình tải lên giấy tờ doanh nghiệp (two-phase process).

Parameters​

PropertyTypeRequiredDescription
miniAppIdLongtrueID của Mini App
fileFiletrueTệp giấy tờ cần tải lên
fileNameStringtrueTên tệp (SDK Node.js yêu cầu, server sử dụng để hiển thị/fileName trả về)
documentTypeStringfalseTên loại giấy tờ (legacy, tương ứng với documentTypeId nếu có)
subCategoryIdIntegerfalseID danh mục con liên quan tới giấy tờ
Định dạng và kích thước tệp
  • Kích thước tối đa: 5 MB
  • Định dạng được hỗ trợ: pdf, png, jpg, jpeg

Return Values​

PropertyTypeDescription
errorintMã lỗi của kết quả trả về, bằng 0 nếu request thành công
messageStringLời nhắn chi tiết tương ứng với mã lỗi
dataObjectThông tin tệp đã tải lên

Data Object​

PropertyTypeDescription
fileIdStringID của tệp đã tải lên (dùng cho bước 2)
fileNameStringTên của tệp đã tải lên

Sample Code​

import java.io.File;

import com.vng.zalo.miniapp.openapi.sdk.models.documents.request.UploadDocumentFileRequest;
import com.vng.zalo.miniapp.openapi.sdk.models.documents.response.UploadDocumentFileResponse;

File testFile = new File("/path/to/your/document.pdf");

UploadDocumentFileRequest request = new UploadDocumentFileRequest();
request.setMiniAppId(YOUR_MINI_APP_ID);
request.setFile(testFile);

UploadDocumentFileResponse response = client.uploadDocumentFile(request);

// Lấy fileId để sử dụng trong bước tiếp theo
String fileId = response.getData().getFileId();
String fileName = response.getData().getFileName();