Support Topics Documentation Slack YouTube Blog

Adding relation between image in file storage and data table

How do I set or add relation to an image file in file storage with a column in data table programmatically without using console.

Hi @Yomade_Stephens

FILE_REF is just a string column, so you can work with it as with primitive columns.

public void saveNewPerson()
{
  HashMap person = new HashMap();
  person.put( "name", "Jack Daniels" );
  person.put( "avatar", "https://path/to/avatar.jpg" );
  
  // save object synchronously
  Map savedPerson = Backendless.Persistence.of( "Person" ).save( person );

  // save object asynchronously
  Backendless.Persistence.of( "Person" ).save( person, new AsyncCallback<Map>() {
      public void handleResponse( Map response )
      {
        // new Person instance has been saved
      }

      public void handleFault( BackendlessFault fault )
      {
        // an error has occurred, the error code can be retrieved with fault.getCode()
      }
    });
}

https://backendless.com/docs/android/data_single_object_create.html#example

Regards, Vlad

Don’t think this is related to what I need. Take an instance I uploaded an image file to backendless storage as user display image, to get the url I need to create a relation of the current user to that image file to show the image to the user as display image. Api to set relation needed if available without using console.

@Yomade_Stephens, Vlad gave you correct advice. If you store file path as a string it will be treated by backendless as a relation. Just try to store the file url and go to console, you will see it as relation.

Figured it out. Tanx guys.