SkygearIO / skygear-SDK-Android

Skygear Android SDK
Other
12 stars 36 forks source link

Pre-save asset with record cause app crash #248

Closed carmenlau closed 6 years ago

carmenlau commented 6 years ago

When saving record with new asset, it calls Database.findInObject recursively and cause app crash.

Testing code:

String base64String = "<base64image>";
byte[] decodedString = Base64.decode(base64String, Base64.DEFAULT);
Asset asset = new Asset("test.png", "image/png", decodedString);

Record newRecord = new Record("Demo");
newRecord.set("attachment", asset);

skygear.getPublicDatabase().save(newRecord, new RecordSaveResponseHandler(){
    @Override
    public void onSaveSuccess(Record[] records) {
        Record record = records[0];
        Object a = record.get("attachment");
        if (a instanceof Asset) {
            Log.d("onSaveSuccess", ((Asset) a).getUrl());
        }
    }

    @Override
    public void onPartiallySaveSuccess(Map<String, Record> successRecords, Map<String, Error> errors) {
    }

    @Override
    public void onSaveFail(Error error) {
    }
});