Page 2 of 2

Upload FIles to a Database Collection

Posted: Fri Dec 26, 2014 4:46 pm
by Mike6979865

Got it, I'll try that.

Regards,


Upload FIles to a Database Collection

Posted: Mon Dec 29, 2014 8:50 pm
by Mike6979865

How do I query the file names for a specific user? I will create a list, and have the userid populate in a label, and then query files for that specific user id. Should I add a where? What should the return code be?


Upload FIles to a Database Collection

Posted: Mon Dec 29, 2014 11:34 pm
by Yurii Orishchuk

Hi Mike,

Unfortunatly "where" filter is not available for system Files collection..

You have two ways to solve this issue:

  1. Create server script that will get all files and filter them by Owner.

  2. Create user_files collection(fileName: string, user: pointer_to_users). With this collection - you can link all files with user you need. Then you can access/edit/filter this collection like you need(for example - get all files by current user).

    Regards.


Upload FIles to a Database Collection

Posted: Tue Dec 30, 2014 6:49 pm
by Mike6979865

Hi,
For testing purposes, I created fileName: string, and user: and pointed user to users. I manually enter the user id as show in this screenshot:
Image

I then mapped filename to to files label so when I use the listing there, I can see the file names for certain users:

Image

However, when I run the list service, I see undefined in the files label:

Image

Is there a reason why?

Regards,


Upload FIles to a Database Collection

Posted: Wed Dec 31, 2014 12:26 am
by Yurii Orishchuk

Hi Mike,

It seems you have wrong service response parameters.

You should have "file_name" string response parameter. Currently i see only "Files" which is an object.

Also please show us your full mapping screen shot(not cropped). In you one - i can not see details.

Regards.


Upload FIles to a Database Collection

Posted: Wed Dec 31, 2014 4:49 pm
by Mike6979865

Please see screenshot.
Image


Upload FIles to a Database Collection

Posted: Wed Dec 31, 2014 5:39 pm
by Mike6979865

I think it has to be done in the upload service. I managed to show the file name. I referred to this solution: https://getsatisfaction.com/apperyio/...
So far, I'm making progress. I'm able to display the file using this command:

console.log(data);
alert(data[0].success.filename);.

However, only one file is being displayed. My intention is store store the multiple files names in an array. I need to list them later on when I use the listing service.

Here's what I need to do, and what I need assistance with:

I managed to create the upload service. I managed to display the file name after the file is uploaded. I need to store the filenames uploaded into a local storage variable so when I use the create service after the files get uploaded, the file names go into the applications collection along with the user details/property types... What code should I use to do that?

Regards,


Upload FIles to a Database Collection

Posted: Thu Jan 01, 2015 12:08 am
by Yurii Orishchuk

Hi Mike,

It seems you have several wrongs in implementation.

Common plan to do it:

  1. Upload file, and store "fileName" to LSV(please check whether you have correct filename in this LSV).

  2. Modificate your list/create service. This services should have "file_name" string-type parameter. Currently you have "files" that's an object. Also you can just delete these services and import from DB them again.

  3. In create service (for collection where you added "file_name" field) datasource mapping find "file_name" request parameter and click on "JS". Then populate it with following code:

    pre

    //where "db_file_name" is LSV name where you store file name from 1st step.
    return localStorage.getItem('db_file_name');

    /pre

    Regards.


Upload FIles to a Database Collection

Posted: Tue Jan 20, 2015 8:54 pm
by Mike6979865

How do I store fileName to LSV. I tried mapping filename on success to db_file_name. It didn't work.


Upload FIles to a Database Collection

Posted: Wed Jan 21, 2015 11:31 am
by Ihor Didevych

Hi Mike,

You can use simple local storage or Appery.io storage
1) localStorage.setItem("file_name", "myfile.jpg");
2) Apperyio.storage.file.set("myfile.jpg"); // don't forget to create a variable in Modal and Storage of App project
http://devcenter.appery.io/documentat...