我想上傳一個圖像,保存在我的手機的內存,點擊一個Android應用程序到雲服務,並使用Kinvey這樣做。但我正面臨着一些問題。試圖上傳一個圖像從Android應用程序到雲使用kinvey
每次我運行包含上傳部分的代碼時,都會遇到異常。我正在上傳「.png」類型的圖片。與谷歌雲平臺不同,任何轉換爲斑點的過程都不是必需的過程。
這裏是我的.java代碼 -
`Client mKinveyClient = new Client.Builder(APP_KEY, SECRET_KEY, this.getApplicationContext()).build();
mKinveyClient.enableDebugLogging();
mKinveyClient.ping(new KinveyPingCallback() {
public void onFailure(Throwable t) {
Log.e(TAG, "Kinvey Ping Failed", t);
}
public void onSuccess(Boolean b) {
Log.d(TAG, "Kinvey Ping Success");
}
});
java.io.File file = new java.io.File(Environment.getExternalStorageDirectory().getPath() + "/Camera/" + "IMG_20161115_193353.jpg");
mKinveyClient.file().upload(file, new UploaderProgressListener() {
public void onSuccess(Void result) {
Log.i(TAG, "successfully upload file");
}
@Override
public void onSuccess(FileMetaData fileMetaData) {
Log.i(TAG, "successfully uploaded file");
}
@Override
public void onFailure(Throwable error) {
Log.e(TAG, "failed to upload file.", error);
}
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
Log.i(TAG, "upload progress: " + uploader.getUploadState()); // all updates to UI widgets need to be done on the UI thread
}
});`
如今,雖然平安電話是給我一個成功的響應,上傳的部分是給我的錯誤。
E /活動文件:未能上傳文件。 com.kinvey.java.KinveyException: 理由:目前沒有用戶登錄
我搜索關於這個主題很多,在kinvey的討論平臺,在這裏太。但我仍然堅持。我不知道我要去哪裏錯,或者我可能會錯過什麼。
如果有人已經成功地通過kinvey上傳圖片,請幫助我。