---
# System prepended metadata

title: ABC 檔案上傳串接 Documentation

---

# ABC 檔案上傳串接 Documentation
### [Swagger API Url](https://exebrain.ms.lightup.tw/api-docs)
TO ABC 的tag是下面會用到的api
![image](https://hackmd.io/_uploads/ryVQlZHUkg.png)
## 權限說明
當執行下列api 時需要給的是c端token, 因為這些行為都需要c端授權,在該 booking 裡已有授權token, 最長7天
## Endpoints
## 1 Upload files
### 1.1 `POST /a2/getUploadUrl`
- **Description**: Retrieves upload URLs for the specified file IDs.
- 取得上傳url,並確認所上傳資料清單,當重新call這個api時,舊有的檔案會全清除.
-  當檔案裡有  "montage_ec.tdt,  montage_eo.tdt" 時,並全部檔案都上傳完成時,才會產生分析報告.
- 根據 body 的 type 分 ec or eo
- **Request Body**:
  - `bookingId` : from the web page of A2.
  - Calculate the size(byte) and md5(base64) of each file.
  
  ```json
   {
  "bookingId": "1735784067246:0264455b-5370-4567-ab51-ca3d5f6e5a05",
  "files": [
    {
      "fileName": "montage_ec.tdt",
      "size": 179200,
      "md5": "6OMb/XNaeVxqVDHddd6k7A=="
    },
    {
      "fileName": "montage_eo.tdt",
      "size": 179200,
      "md5": "6OMb/XNaeVxqVDHddd6k7A=="
    },
    {
      "fileName": "montage.model",
      "size": 179200,
      "md5": "6OMb/XNaeVxqVDHddd6k7A=="
    }
  ], 
       
    "type": "ec"
}
    ```
- **Response**: The upload URLs for the specified files .
```json
{
  "files": [
    {
      "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/string/1735784067246%3A0264455b-5370-4567-ab51-ca3d5f6e5a05/montage_ec.tdt?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T100632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Goog-Signature=8d5c5a0a1e183d3bd13bde1bf0488d3ee036df8a6545b5ac507f0d1b1bbd32f303ca7f910faf28556beded73b91aac2cafad90eec69972dec3bc74e2f0b1e0e26a83700ae7b8326d66813a486511c23ec33053715ab45e7a2e314d4aa797f78ada453f3049165653c4baf17622ad73f4c0ebd224ed09f6f562fe8a304bffdee08c8de7d2d91bb6505aefa9ef3b0781f5c6d28e2a63c4c782fbc9ce3574178c1da0f12edb16954ada6fd39719ccfb92c5e02410adaea3e9091e5762d2baf1cdcc62518827fd4c74d4f7f952199ab49f25005678030ec9d1a3bd8d561a188c5d38a95b4fb2bddd2a04256001feac8351a573dd7b3eeb97cd1225ee9b3a94d28127",
      "metadata": {
        "id": "fileRecord-1735812392599-e33",
        "fileName": "montage_ec.tdt",
        "size": 179200,
        "type": "file",
        "md5": "6OMb/XNaeVxqVDHddd6k7A=="
      }
    },
    {
      "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/string/1735784067246%3A0264455b-5370-4567-ab51-ca3d5f6e5a05/montage_eo.tdt?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T100632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Goog-Signature=26b56dadc076d51e3f27f8830c8084e0ad8a9fa02997351204d5ab1207ee9af6d4c00fcc232079e4bae94146eee3d6d49ff6cfc64a476c48824268ac860cf19bda310285e50d0ec40a5b46a17dd0ec7a81267690b5c6a415dfd3fd485521ccb9210c2d09fb8722bc679c5eff0d189742a4c3c7e463eea9aabcb5d5d58aeac732975974a59b8a4d34404c2e211a23fdd7823f9533f9e275c65f4afef2a84557df616284d13621570a77ce59cca5b1a7caf5d184a7d7915f3fa04c7d6f6fa58f150dab1d3b02ecea9d87858dbf26165bbbfa28c9e9ee47a17f62c1a24db022cbb0be39906c0c058240a2b17d9c4923c4679963ac666daa7a4cdcf46fbec8e945e1",
      "metadata": {
        "id": "fileRecord-1735812392600-1e7",
        "fileName": "montage_eo.tdt",
        "size": 179200,
        "type": "file",
        "md5": "6OMb/XNaeVxqVDHddd6k7A=="
      }
    },
    {
      "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/string/1735784067246%3A0264455b-5370-4567-ab51-ca3d5f6e5a05/montage.model?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T100632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-md5%3Bcontent-type%3Bhost&X-Goog-Signature=1e6824010265146d95953f11009d9d3894f825124271ab0eb166c97d752d49efc141278158bd9851ac56dd390f8dece5fa38cf7b26cda8e45be55a586ab53b0c37e3bc1abf71b62a91b61849d9d24d18f98aed924882b95379fe9498bde1896a6956a395c73123421f6749886be77f287e9f505c70cd89174bf73ac140a010c576aa662b1b265713c689740083fb5fa2bcfda64ddf8291392bd7e1cef40a55b57e60088dcd56d80d188d038f1e3d090004b48d294d630e7632624d77d2aeb11cca24e5ff855d60342332f04ed8bba51cab2258316ca60240a90e1aecbd29709bad280abfd76fddae0ed5376a331b2a0a3c915b37b233d4f0099b3cf67a226c2e",
      "metadata": {
        "id": "fileRecord-1735812392601-904",
        "fileName": "montage.model",
        "size": 179200,
        "type": "file",
        "md5": "6OMb/XNaeVxqVDHddd6k7A=="
      }
    }
  ]
}
```

### 1.2 Upload files to above Urls.
```javascript    
    
    const uploadFile = async (signedUrl, fileBuffer, fileMd5) => {
    try {
        const response = await axios.put(signedUrl, fileBuffer, {
            headers: {
                'Content-MD5': fileMd5,
                'Content-Type': 'application/octet-stream'
            }
        });
        if (response.status === 200) {
            console.log('File uploaded successfully');
        } else {
            console.log('Failed to upload file', response.statusText);
        }
    } catch (error) {
        console.error('Error uploading file:', error);
    }
};
```
### 1.3 `POST /a2/getUploadStatus`
- Get the status of each uploaded file.
- **Request Body**:
- id is from the response of step 1's metadata.
```json
  "id": [
    "fileRecord-1735812392599-e33",
    "fileRecord-1735812392600-1e7",
    "fileRecord-1735812392601-904"
  ]
```
- **Response**
```json
 [
  {
    "message": "upload success"
  },
  {
    "message": "upload success"
  },
  {
    "message": "upload success"
  },
]
```
- Make sure that every file is  uploaded successfully.
## 2. Download model files
### 2.1 `GET a2/getModels`
- **Request Body**:
    (None) Automatically get from login token.
- - **Response Body**:
```json
[
  {
    "bookingId": "1735784067246:0264455b-5370-4567-ab51-ca3d5f6e5a05",
    "fileName": "montage.model",
    "id": "ileRecord-1735812392599-e33"
  },
  {
    "bookingId": "1735784067246:0264455b-5370-4567-ab51-ca3d5f6e5a05",
    "fileName": "montage.model",
    "id": "ileRecord-1735812392599-e33"
  }
]
```
- Take the id to get downlod url with step 5.
### 2.2 `POST /a2/getDownloadUrl`

- **Request Body**:
- id is from step 4's response
```json
{
  "id": [
    "fileRecord-1715311685215-977",
    "fileRecord-1715311684630-3ee",
    "fileRecord-1715311684620-abc"
  ]
}
```
- **Response Body**:
```json
[
  {
    "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/c8c357bc-97ec-4d68-a0ab-147780b37ed0/0d9adef9-0db6-4ec4-b4e5-427f3b6315da/ea8d51c1-c639-4eee-85bb-46728d6dd717.png-preview/320.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T105632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtest1-pre-320.png&X-Goog-Signature=134a67ba9952e50900a70132f2fb7c919751c90432e85bed002744d114854a089528df186fb5a24ae46315d79b825c83bc16d8545fa8aa240f72e94ea30142c466dd1e2d14ee2412aa04ddbfecbf06c907f10666a4a94a5b811ef9b33ed97440b8295271c67375e6598d1dc2d93ea1c7a9ceec8ea6d53b875d18421297c345dd408078811c84e384699ad204e735c18a58402cd1b19ae912225fa6801dd60b26a639acc91dc4e623b763c78b9bb9badfb1d91e9679c59618686f57434ad0f423a220f48a3b7a6e129693906ed4a46c402250aaeeca4bc7ab96b4f464e1b15480c05554d8878a3f671ffe5c3decf7b35b2c932515acda35e474adf3cedefb7ad1"
  },
  {
    "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/c8c357bc-97ec-4d68-a0ab-147780b37ed0/0d9adef9-0db6-4ec4-b4e5-427f3b6315da/ea8d51c1-c639-4eee-85bb-46728d6dd717.png-preview/320.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T105632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtest1-pre-320.png&X-Goog-Signature=134a67ba9952e50900a70132f2fb7c919751c90432e85bed002744d114854a089528df186fb5a24ae46315d79b825c83bc16d8545fa8aa240f72e94ea30142c466dd1e2d14ee2412aa04ddbfecbf06c907f10666a4a94a5b811ef9b33ed97440b8295271c67375e6598d1dc2d93ea1c7a9ceec8ea6d53b875d18421297c345dd408078811c84e384699ad204e735c18a58402cd1b19ae912225fa6801dd60b26a639acc91dc4e623b763c78b9bb9badfb1d91e9679c59618686f57434ad0f423a220f48a3b7a6e129693906ed4a46c402250aaeeca4bc7ab96b4f464e1b15480c05554d8878a3f671ffe5c3decf7b35b2c932515acda35e474adf3cedefb7ad1"
  },
  {
    "url": "https://storage.googleapis.com/c8c357bc-97ec-4d68-a0ab-147780b37ed0/c8c357bc-97ec-4d68-a0ab-147780b37ed0/0d9adef9-0db6-4ec4-b4e5-427f3b6315da/ea8d51c1-c639-4eee-85bb-46728d6dd717.png-preview/320.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=35741043469-compute%40developer.gserviceaccount.com%2F20250102%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250102T105632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtest1-pre-320.png&X-Goog-Signature=134a67ba9952e50900a70132f2fb7c919751c90432e85bed002744d114854a089528df186fb5a24ae46315d79b825c83bc16d8545fa8aa240f72e94ea30142c466dd1e2d14ee2412aa04ddbfecbf06c907f10666a4a94a5b811ef9b33ed97440b8295271c67375e6598d1dc2d93ea1c7a9ceec8ea6d53b875d18421297c345dd408078811c84e384699ad204e735c18a58402cd1b19ae912225fa6801dd60b26a639acc91dc4e623b763c78b9bb9badfb1d91e9679c59618686f57434ad0f423a220f48a3b7a6e129693906ed4a46c402250aaeeca4bc7ab96b4f464e1b15480c05554d8878a3f671ffe5c3decf7b35b2c932515acda35e474adf3cedefb7ad1"
  }
]
```
- Take the url to download model files for furture use.

### 圖文流程
1. 鍛鍊師登入
![image](https://hackmd.io/_uploads/S1Yp0G68yl.png)
2. 選擇預約
點選上面的 未報到預約 or 未完成預約 可以切換
![image](https://hackmd.io/_uploads/B1RBg7pI1x.png)

2-1-1. 未報到預約
![image](https://hackmd.io/_uploads/Hy4fkXaUyx.png)
2-1-2. c端客戶登入 
![image](https://hackmd.io/_uploads/Sk_5xXaUkl.png)

2-2-1. 未完成預約
![image](https://hackmd.io/_uploads/HyeMlQa8yx.png)


3. **等待上傳**
此時拿c端token在 軟體上做上傳檔案等動作.
如果此時跳出網頁回2-2-1重新上傳
![image](https://hackmd.io/_uploads/HJjeZQTL1x.png)

4. 如果在軟體上傳完成call 之前javascript 的完成通知的function,目前沒接軟體,所以按
"分析結束,上傳報告後由軟體通知網頁"
5. 報告預覽生成中 exebrain service server 抓取上傳的檔案生成報告 
![image](https://hackmd.io/_uploads/BkcDzQaUkx.png)
6. 預覽html 的報告


### 測試幫助

![image](https://hackmd.io/_uploads/HyR3HmTUkg.png)
如果用function抓不到 c token or bookingId: 
session_storage裡的
access_token_c_user
processingBookingId 
可以看的到



