【问题标题】:Could not upload image using Parse Server and Android无法使用 Parse Server 和 Android 上传图像
【发布时间】:2017-01-23 11:55:34
【问题描述】:

通过图像上传迁移到 Parse Server 后出现错误:“文件上传无效”。

使用 android-parse 1.13.1 和 parse-server 2.3.2。

向新的 ParseFile 添加 Content-Type "image/png" 不能解决问题。

代码:

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));

请帮忙!

【问题讨论】:

    标签: android mongodb parse-platform parse-server parse-android-sdk


    【解决方案1】:

    已解决,我的部分代码错误:

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

    不向服务器发送空字节数组后,问题解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多