2017-01-23 4 views
0

画像のアップロードでParse Serverへの移行後にエラーが発生しました:「無効なファイルのアップロード」。Parse ServerとAndroidを使用して画像をアップロードできませんでした

android-parse 1.13.1とparse-server 2.3.2を使用してください。

Content-Type "image/png"を新しいParseFileに追加しても問題は解決しません。

コード:

private ParseFile getParseFile(Bitmap file, String filename) { 
     // Convert it to byte 
     ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
     // Compress image to lower quality scale 1 - 100 
     file.compress(Bitmap.CompressFormat.PNG, 100, stream); 
     byte[] image = stream.toByteArray(); 
     return new ParseFile(filename, image, "image/png"); 
    } 

ParseFile squarePhotoFile = getParseFile(squarePhoto, "square_photo.png"); 
squarePhoto.recycle(); 
squarePhotoFile.saveInBackground(new SaveInBackgroundSquarePhotoCallback(squarePhotoFile)); 

助けてください!解決

答えて

0

、私のコードの一部が悪かった:

ParseFile squarePhotoFile = new ParseFile("empty", new byte[]{}); 
squarePhotoFile.saveInBackground(new SaveInBackgroundSquarePhotoCallback(squarePhotoFile)); 

サーバに空のバイト配列を送信していない後、問題が解決しました。

関連する問題