Saving jpg to File Storage, then inmediately asigning the returned url to a String field and uploading results in PlatformException(8023)

PlatformException(8023, Validation for the ‘imgEdificioUrl’ property failed. Property value does not match the required pattern)

this is the url of my test image: https://backendlessappcontent.com/859418E3-AA83-93D2-FF8E-C0009E704C00/console/kqkpiwxifurbrbjhnhcbtfthwpjxhkrxzikf/files/view/fotos_parqueaderos/IMG-20191129-WA0060.jpg

I have other fields with urls like this from google images search results, etc and they all work.

Our goal is to easily upload and download images associated to data objects like buildings, parking slots and users.

This is my code:

    void _saveParkingSpot() async {
        /// Sube Parqueadero y actualiza datos del usuario dueño
        String urlParki;
        String urlEdif;

        Backendless.files.upload(fotoEd, "/fotos_parqueaderos").then((response) {
          urlParki=response;
        });

        Backendless.files.upload(fotoParki, "/fotos_parqueaderos").then((response) {
          urlEdif=response;
        });

        Map parki = {
          "name": edificio,
          "disponible": true,
          "imgEdificioUrl": "$urlEdif",
          "imgParqueaderoUrl": "$urlParki",
          "latitude": coordinates.latitude,
          "longitude": coordinates.longitude,
        };

        await Backendless.data.of("Parqueaderos").save(parki);
}

Hi @Samuel_Franco

I’m not familiar with Dart syntax, but I assume there must be await keyword before async operations

await Backendless.files.upload(...

have you tried to add breakpoint on this line:
await Backendless.data.of("Parqueaderos").save(parki);

and debug what value do these variables urlParki and urlEdif contain before saving a new Data object

Regards, Vlad

Hi @Samuel_Franco

As Vladimir mentioned, there should be await keyword before upload operation.
The problem is, upload operation is asynchronous. In your code snippet,
Backendless.files.upload()
and
Backendless.data.of("Parqueaderos").save()
operations run in the same time so the value "$urlEdif" of imgEdificioUrl field is always null and therefore doesn’t match your pattern.

Best Regards,
Maksym

The code should be like this:

void _saveParkingSpot() async {
    /// Sube Parqueadero y actualiza datos del usuario dueño
    String urlParki;
    String urlEdif;

    await Backendless.files.upload(fotoEd, "/fotos_parqueaderos").then((response) {
      urlParki=response;
    });

    await Backendless.files.upload(fotoParki, "/fotos_parqueaderos").then((response) {
      urlEdif=response;
    });

    Map parki = {
      "name": edificio,
      "disponible": true,
      "imgEdificioUrl": "$urlEdif",
      "imgParqueaderoUrl": "$urlParki",
      "latitude": coordinates.latitude,
      "longitude": coordinates.longitude,
    };

    await Backendless.data.of("Parqueaderos").save(parki);

}