写真や小さい tailored audiencesをアップロードする際には、通常64MB以下のサイズになるので、非分割アップロードを使用することができます。
以下が、写真を非分割アップロードする例です:
POST /1.1/ton/bucket/{bucket} HTTP/1.1
Host: ton.twitter.com
Content-Type: image/jpeg
Content-Length: {number_of_bytes}
Authorization: OAuth oauth_consumer_key="XXXXXXXXXX", oauth_nonce="XXXXXXXXXX", oauth_signature="XXXXXXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1426878860", oauth_token="XXXXXXXXXX", oauth_version="1.0"
{image bytes}
Single Chunk UploadPhoto uploads and small tailored audiences will typically be under 64MB and can use non-resumable upload. An example non-resumable photo upload request:
POST /1.1/ton/bucket/{bucket} HTTP/1.1
Host: ton.twitter.com
Content-Type: image/jpeg
Content-Length: {number_of_bytes}
Authorization: OAuth oauth_consumer_key="XXXXXXXXXX", oauth_nonce="XXXXXXXXXX", oauth_signature="XXXXXXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1426878860", oauth_token="XXXXXXXXXX", oauth_version="1.0"
{image bytes}
|
応答は以下のようになります:
HTTP/1.1 201 OK
Date: Wed, 05 Nov 2014 22:50:16 UTC
Content-Length: 0
Location: /1.1/ton/bucket/{bucket}/AzGxDfEg_Hj.jpg
アップロードが完了したら、後でTwitter APIの呼び出しで使う場合に備えて Location ヘッダを保存してください。
|
The response:
HTTP/1.1 201 OK
Date: Wed, 05 Nov 2014 22:50:16 UTC
Content-Length: 0
Location: /1.1/ton/bucket/{bucket}/AzGxDfEg_Hj.jpg
Once completed, the |