Spark Chao
Posts: 0
Joined: Sat Jan 17, 2015 6:25 am

use Facebook access token to upload file?

today I try to set the upload file function in my app.
but following the tutorials "Uploading files to the Appery.io database".
I find the x-appery-session-token must be mapping.
can I map the access_token which Facebook provided to upload file?
or this function only working by use appery user login?

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

use Facebook access token to upload file?

Think of the token coming from Facebook as a 'uniqueifier' to distinguish one Facebook user from another and to possibly use to establish credentials in your app.

The session token on the other hand is a database access and permission to use the db and related services token. Whenever hitting the Appery platform with data ... You need to use that token ...

Not sure if that helps ....

Bruce

Spark Chao
Posts: 0
Joined: Sat Jan 17, 2015 6:25 am

use Facebook access token to upload file?

Bruce
Thanks for your reply!!
Because I use Facebook login service rather than appery.io user login service.
So I only can get the access_token form Facebook .
Do you have any suggestion to get the x-appery-session-token without appery.io user login service.
Or it must should use appery.io user login service to upload file?

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

use Facebook access token to upload file?

Spark,

When I get the data back from Facebook, in the Facebook return method, I create a user ID ( first name + last name plus Fscebook id token ( the one that's the same each time ) and password ( I use the token as the password) and I pass these to the login service ... If the service fails ( in the failure event ), I create a new user ( first time this user has used my app ) with the credentials I just mentioned.

That creates a user ID and login for each unique users from Facebook. I can track their activity and give hem each sessions on the db. I like this as I believe it's more secure.

Another route, likely less recommended, would be to have each instance of you app login with your master key. I'd be careful with using this approach ... As having your master credentials get hacked would be very bad. That said... Risk v time v reward is always worth understanding. In this approach if you needed to track db activity back to users you could add a field to any collections where the users added data... And push the Facebook token to a column there,

Hope that helps. If not ... Someone from appery might be able to give you a more enlightened response....

Best,

Bruce

Spark Chao
Posts: 0
Joined: Sat Jan 17, 2015 6:25 am

use Facebook access token to upload file?

Bruce
thank you again!!!
u give me a very clear guide to solve it.
I will try it ,and let you know I success or not!

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

use Facebook access token to upload file?

Spark,If you need some sample code ... I've got some ... Best of luck ! Bruce

Spark Chao
Posts: 0
Joined: Sat Jan 17, 2015 6:25 am

use Facebook access token to upload file?

Bruce
I already did it! the way you suggested is perfect!!
but I meet another question need you help.

in my app,user can select one picture represent the location.
Image

but when I upload the picture to the file succeed.
Image

I can't get the file_name back to record in the column of location collection.
how can I did that?
or my logic is wrong?
thanks

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

use Facebook access token to upload file?

Spark,

Sorry - away from my desk this morning. Let me make sure I understand the challenge..... your user is selecting a picture to represent their location (I assume from their device - correct?)

You're then uploading the file using the file loader service (which I'm probably not as familiar with as I should be since when my users load photos - I go directly to a column in my db).... and then you need to refer to it (the file name) in your DB?

Can you explain in a bit more detail?

As a general rule however, I would say that the picture loading mechanism can return either the file name location itself or the 64bit representation that you can load to the location of your choice. Any results that come out of this service could also be stored to a memory variable - and then used in the next service - which would be to load the file to your datastore. I know that's what I do with my images (store them to a memory variable along with a uniqueifier and then load them in the next service (which I call from the camera success event ) - and map the memory variables to the data service.

Not sure if that helps or not. Might need to get the Appery team involved here.....

best,
Bruce

Spark Chao
Posts: 0
Joined: Sat Jan 17, 2015 6:25 am

use Facebook access token to upload file?

Thanks for your patient!
I explain more clearly what I expect to do on my app.
Maybe you can suggest me another more efficient way to do that.
1、edit page:select a picture and fill in the information.
in my way,I use the uploadService to upload picture to file collection of db.
Image
and this step is work right now.
Image

2、create a row:then user click the button"share the spot!",will invoke the create service of spot detail.but the column of photo still empty.
Image
Image

Should I have to follow you suggestion to upload photo directly to the column in my collection(collection:spot detailcolumn:photo)?

If I follow the tutorial "Using the camera component",can I select a existing photo from user's phone album,rather than take a new one?

thanks you again!!!!!

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

use Facebook access token to upload file?

Hi Spark,

Sorry for the long delay - was off yesterday with the family.

In opposite order - yes - you can select an item from an existing photo (or use the camera). What I do is I have a popup where I ask the user if they want to use camera or use the album. Then - I map this response to my camera event - I map that to the selector for the camera event (shown below):

Image

Return to “Issues”