結果與下載
每個已完成的任務都會列出結果,每個結果都附有下載連結。需要新連結時,隨時重新取得工作即可。
本頁內容
GET /v1/jobs/{id} 會在每個任務的 outputs 中列出結果:
| 欄位 | 說明 |
|---|---|
file_id | 結果的 ID。 |
name | 檔名。 |
size | 大小,以位元組為單位。 |
download_url | 下載連結。 |
download_expires_at | 連結失效的時間。 |
下載連結的有效期限為 7 天或結果遭刪除前的剩餘時間,以較短者為準。重新取得工作即可獲得新連結。連結會以檔名下載檔案,而且不需要金鑰,因此在連結過期之前,任何持有連結的人都能下載檔案:請勿公開連結。
# 每個結果的 download_url 都在工作中。連結不需要金鑰。
curl https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517 \
-H "Authorization: Bearer $FILESOKAY_KEY"
curl -o lecture-compressed.mp4 "$DOWNLOAD_URL"import fs from "node:fs";
import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";
const res = await fetch(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517",
{ headers: { Authorization: `Bearer ${process.env.FILESOKAY_KEY}` } },
);
const job = await res.json();
for (const task of job.tasks) {
for (const output of task.outputs) {
const file = await fetch(output.download_url);
if (!file.ok) throw new Error(`${output.name}: ${file.status}`);
await pipeline(Readable.fromWeb(file.body), fs.createWriteStream(output.name));
}
}import os
import requests
job = requests.get(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517",
headers={"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}"},
).json()
for task in job["tasks"]:
for output in task["outputs"]:
with requests.get(output["download_url"], stream=True) as res:
res.raise_for_status()
with open(output["name"], "wb") as f:
for chunk in res.iter_content(chunk_size=1 << 20):
f.write(chunk)| 檔案 | 刪除時間 |
|---|---|
| 從未完成的上傳 | 開始後 7 天 |
| 已完成但沒有工作使用的上傳 | 完成後 24 小時;10 GiB 以上的檔案為 3 天 |
| 已完成任務的輸入檔案 | 任務完成後 60 分鐘 |
| 失敗或已取消任務的輸入檔案 | 任務結束後 24 小時 |
| 工作的結果 | 產生後 3 天;任務的輸入檔案超過 5 GiB 時為 7 天,超過 20 GiB 時為 10 天 |
每個檔案的 delete_at 會顯示其刪除時間。
DELETE /v1/jobs/{id}/files 會立即刪除已結束工作的輸入檔案和結果。工作本身及其點數紀錄會保留。執行中工作的檔案無法刪除:請先取消工作。
curl -X DELETE https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
console.log(res.status);import os
import requests
res = requests.delete(
"https://api.filesokay.com/v1/jobs/job_a1c9531eeb00434aba0058796f1ca517/files",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
print(res.status_code)DELETE /v1/files/{id} 會立即刪除一個已上傳的檔案。兩者都無法復原。