我正在尝试将照片上传到 Flickr,但此代码引发了找不到文件的异常。图像在文件夹中,但我不知道为什么 Android 会引发异常。请帮忙。
OAuthRequest request = new OAuthRequest(Verb.POST,
"http://api.flickr.com/services/upload/");
service.signRequest(accessToken, request);
MultipartEntity entity = new MultipartEntity();
entity.addPart("photo", new FileBody(new File("/test/res/drawable-hdpi/icon.png"),
"image/png"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
entity.writeTo(out);
request.addPayload(out.toByteArray());
request.addHeader(entity.getContentType().getName(),
entity.getContentType().getValue());
Response response = request.send();
String body = response.getBody();
} catch (IOException e) {
e.printStackTrace();
}