File Upload Endpoints

API Endpoints #

檔案上傳 #

GET v1/credentials #

Endpoint URL: https://tw.buy.yahoo.com/api/fileUploader/v1/credentials
HTTP Method: GET

取得 Temporary Security Credential

Output

Error
HTTP Status Code Error Code Description
400 Invalid input
401 4010001 Missing or bad authentication
401 4010002 Missing or bad wssid
429 4290001 Too many requests, try again later
500 Internal server error

Example

  • Get temporary security credential by cookie
GET /api/fileUploader/v1/credentials
HOST: tw.buy.yahoo.com
Content-Type: application/json; charset=utf-8
Cookie: _sp=<sp cookie>
X-YahooWSSID-Authorization: <wssid>

HTTP/1.1 200 OK

{
  "expiredTs": "2018-03-23T17:35:47+08:00",
  "id": "id-string",
  "key": "key-string",
  "token": "token-string"
}

GET v1/fileObjects/{ETag} #

Endpoint URL: https://tw.buy.yahoo.com/api/fileUploader/v1/fileObjects/{ETag}
HTTP Method: GET

取得檔案 URL
取決於檔案大小與同時間的處理量,檔案上傳至 S3 並取得 ETag 後,可能因為還在 AWS 上處理,會回應 404 Not Found (4040001 Object not found) 訊息,建議在實作時可以非同步的方式同時上傳多個檔案,並每 3 秒重新詢問一次直到成功或依貴單位需求設定重試上限。需注意每次的重試都必須以同樣的 Cookie 與 WSSID 詢問 API。
Parameters
Parameter Name Type Required Note
ETag String Y 成功上傳 AWS S3 後,取得的物件 ETag

Output

  • HTTP Status Code: 200 (OK)
  • Object: Object
Error
HTTP Status Code Error Code Description
400 Invalid input
401 4010002 Missing or bad wssid
404 4040001 Object not found
404 4040002 Type unsupported, the object has been skipped
404 4040003 Object already expired
404 4040004 User abused, the object has been deleted
500 Internal server error

Example

  • Get temporary security credential by cookie
GET /api/fileUploader/v1/fileObjects/etagid1
HOST: tw.buy.yahoo.com
Content-Type: application/json; charset=utf-8
Cookie: _sp=<sp cookie>
X-YahooWSSID-Authorization: <wssid>

HTTP/1.1 200 OK

{
  "expiredTs": "2018-03-26T23:59:59+08:00",
  "id": "etagid1",
  "url": "https://s.yimg.com/nw/Files/3302c543a7bf5fecb7b71c5a61541b346823f189.png",
  "status": "IN_USE"
}