Attachments - Create
上傳附件。
在具有較高附件上傳限制的帳戶上, (> 130 MB) ,您必須使用區塊上傳。 若要在多個區塊中上傳附件,您必須先 啟動區塊上傳 ,然後遵循 [上傳區塊 ] 區段的範例。
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?api-version=5.0
POST https://dev.azure.com/{organization}/{project}/_apis/wit/attachments?fileName={fileName}&uploadType={uploadType}&areaPath={areaPath}&api-version=5.0
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 組織的名稱。 |
|
project
|
path |
string |
專案識別碼或專案名稱 |
|
|
api-version
|
query | True |
string |
要使用的 API 版本。 這應該設定為 '5.0' 以使用此版本的 API。 |
|
area
|
query |
string |
目標專案區域路徑 |
|
|
file
|
query |
string |
檔案的名稱 |
|
|
upload
|
query |
string |
附件上傳類型:簡單或區塊化 |
要求本文
Media Types: "application/octet-stream"
| 名稱 | 類型 | Description |
|---|---|---|
| body |
string |
要上傳的資料流程 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
成功作業 |
安全性
oauth2
類型:
oauth2
Flow:
accessCode
授權 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
權杖 URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
範圍
| 名稱 | Description |
|---|---|
| vso.work_write | 授與讀取、建立及更新工作專案和查詢、更新面板中繼資料、讀取區域和反復專案路徑的其他工作專案追蹤相關中繼資料、執行查詢,以及透過服務勾點接收工作專案事件通知的能力。 |
範例
| Start a Chunked Upload |
| Upload a binary file |
| Upload a text file |
Start a Chunked Upload
範例要求
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=largefile.zip&uploadType=chunked&api-version=5.0
範例回覆
{
"id": "de471719-27b2-40ab-ac40-4890f3eb1443",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/de471719-27b2-40ab-ac40-4890f3eb1443?fileName=test.txt"
}
Upload a binary file
範例要求
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=imageAsFileAttachment.png&api-version=5.0
"[BINARY FILE CONTENT]"
範例回覆
{
"id": "a5cedde4-2dd5-4fcf-befe-fd0977dd3433",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/a5cedde4-2dd5-4fcf-befe-fd0977dd3433?fileName=imageAsFileAttachment.png"
}
Upload a text file
範例要求
POST https://dev.azure.com/fabrikam/_apis/wit/attachments?fileName=textAsFileAttachment.txt&api-version=5.0
"User text content to upload"
範例回覆
{
"id": "6b2266bf-a155-4582-a475-ca4da68193ef",
"url": "https://dev.azure.com/fabrikam/_apis/wit/attachments/6b2266bf-a155-4582-a475-ca4da68193ef?fileName=textAsFileAttachment.txt"
}
定義
AttachmentReference
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string |
|
| url |
string |