getFullUrl for a picture in apstrata without downloading it
  • Hi karim,

    I used to work with ApstrataClientAndroid but it is deprecated now as u previously mentioned, and at that time I used to add the below to get the full url of an image  without downloading it:

    picParams.add(new BasicNameValuePair("apsdb.fileName", "orange.jpg"));
    picParams.add(new BasicNameValuePair("apsdb.fieldName", "file"));
    picParams.add(new BasicNameValuePair("apsdb.documentKey", ad_doc.getString("key")));

    String pictureURL = client1.getFullUrl("GetFile", picParams, AuthMode.COMPLEX);

    My question in Client class what function could I use so that I can get the url of an image given its name 

    I tried using 

    Map<String, List<File>> files = null;
    String pictureURL = client1.getSignedRequestUrl("GetFile", picParams, files, AuthMode.SIMPLE);

    but it not working.

    Thank you.


  • Hello Nour,

    You actually used the correct method but its documentation is not very explicit about what you should do.
    Indeed, what the method does is to generate the first part of the URL with the signature (obtained from your credentials and the parameters you sent) but without adding the parameter names and values to it! 

    As a consequence, you still have to add these yourself to the resulting URL, as in the below example:

    UserConnection connection = null;
    try {
    connection = new UserConnection(BASE_URL, ACCOUNT_KEY, USER_NAME, PASSWORD);
    Client client = new Client(BASE_URL, ACCOUNT_KEY, connection);
    List<NameValuePair> parameters = new ArrayList<NameValuePair>();
    BasicNameValuePair docKey = new BasicNameValuePair("apsdb.documentKey", "filedoc");
    BasicNameValuePair store = new BasicNameValuePair("apsdb.store", "myStoreName");
    BasicNameValuePair fileField = new BasicNameValuePair("apsdb.fieldName", "myFileFieldName"); //e.g. "apsdb_attachments"
    BasicNameValuePair fileName = new BasicNameValuePair("apsdb.fileName", "myFileName"); parameters.add(docKey);
    parameters.add(store);
    parameters.add(fileName);
    parameters.add(fileField);
    String response = client.getSignedRequestUrl("GetFile", parameters, null , AuthMode.SIMPLE);
    response += "apsdb.store=myStoreName&apsdb.documentKey=filedoc&apsdb.fieldName=apsdb_attachments&apsdb.fileName=myFileName";
    System.out.println(response);
    } catch (Exception e) {
    e.printStackTrace();
    // exception handling code
    } finally {
    // clean-up
    }

    Karim
  • Hi Karim,

    I implemented the above:
    response += "&apsdb.store=myStoreName&apsdb.documentKey=filedoc&apsdb.fieldName=apsdb_attachments&apsdb.fileName=myFileName";

    and it is working now

    Thank you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!