我正嘗試將處理中的圖片上傳到Google雲端存儲,但是當我查看存儲時,我只有一個空白圖片。上傳到Google雲端存儲中的圖片只包含空白
我正在使用「HTTP請求處理」庫來上載圖像。
這裏是下面的代碼(更新):
Reponse Content: {
"kind": "storage#object",
"id": "hs_test01/person0.jpg/1468064800417000",
"selfLink": "https://www.googleapis.com/storage/v1/b/hs_test01/o/person0.jpg",
"name": "person0.jpg",
"bucket": "hs_test01",
"generation": "1468064800417000",
"metageneration": "1",
"contentType": "image/jpeg",
"timeCreated": "2016-07-09T11:46:40.413Z",
"updated": "2016-07-09T11:46:40.413Z",
"storageClass": "STANDARD",
"size": "1101980",
"md5Hash": "msH3vhzgwNKPd5aRXfy/vA==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/hs_test01/o/person0.jpg?generation=1468064800417000&alt=media",
"crc32c": "nGKW7A==",
"etag": "COjJvsen5s0CEAE="
}
這裏是教程至今我都遵循:https://cloud.google.com/storage/docs/json_api/v1/how-tos/simple-upload#sending_a_simple_upload_request
有來自API
import http.requests.*;
int number = 0;
void setup(){
size(640,480);
}
void draw() {
if(number < 1) {
PostRequest post = new PostRequest("https://www.googleapis.com/upload/storage/v1/b/hs_test01/o?uploadType=media&name=person0.jpg&access_token=ya29.Ci8aA6-n96angt2d9mIyDUL2_4bHP5ybP-5deHb3zbnpbwFgwAGD5vx2LlydFwCjBA");
File f = new File(sketchPath("data/test.jpg"));
post.addFile("image/jpeg", f);
long size = f.length();
println(size);
post.addHeader("Content-Type","image/jpeg");
post.addHeader("Content-Length","163155");
post.send();
println("Reponse Content: " + post.getContent());
println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
}
number++;
}
響應也是提示,我必須給出圖片的內容長度(它的字節)。難道這是因爲我只收到存儲器中的空白圖像?如果是,我怎樣才能自動讀取圖像的字節? The result of the uploaded pic so far
我一直無法重現此問題。你確定了這個白色圖像的原因嗎?下面提供的答案對此有幫助嗎? – Nicholas
@Nicholas對不起,沒有看到你的評論。沒有遺憾的是,我去了Python並使用谷歌的gsutil工具,然後工作。 – SeGa