testuser
testuser

Reputation: 33

ArrowDB dashboard upload photo to user

when I upload a photo using the arrowdb dashboard on https://platform.appcelerator.com

Cloud.Users.query only shows the photo_id

but whne I created a new user using the dashboard and attached a phot it is showing in the Cloud.Users.query

eg . photo uploaded after user created

{
"id": "563019f18cb04aede69e2111",
"first_name": "store1",
"last_name": "123",
"created_at": "2015-10-28T00:42:25+0000",
"updated_at": "2016-01-22T08:59:44+0000",
"external_accounts": [],
"confirmed_at": "2015-10-28T00:42:25+0000",
"username": "user",
"admin": "false",
"stats": {
    "photos": {
        "total_count": 0
    },
    "storage": {
        "used": 0
    }
},
"photo_id": "56a1dc083a654d090d126792",
"friend_counts": {
    "requests": 0,
    "friends": 0
}

}

eg. photo uploaded while creating user

  {
"id": "56a1f0333a65234234390d7",
"first_name": "qqqq",
"last_name": "wwwe",
"created_at": "2016-01-22T09:02:43+0000",
"updated_at": "2016-01-22T09:07:18+0000",
"external_accounts": [],
"confirmed_at": "2016-01-22T09:02:43+0000",
"username": "qwe",
"admin": "false",
"stats": {
    "photos": {
        "total_count": 0
    },
    "storage": {
        "used": 0
    }
},
"photo": {
    "id": "56a1f0333a654d090d0390d8",
    "filename": "userPhoto.jpg",
    "size": 25394,
    "md5": "e20f4fcadf6cde9fccfb458dd11951d4",
    "created_at": "2016-01-22T09:02:43+0000",
    "updated_at": "2016-01-22T09:02:43+0000",
    "processed": true,
    "urls": {
        "original": "https://s3-us-west-1.amazonaws.com/storage-platform.cloud.appcelerator.com/xmqh1djNEIChtQFP6d37HNH5DQNCXQoX/photos/51/d4/56a1f0333a654d090d0390d9/userPhoto_original.jpg"
    },
    "content_type": "image/jpeg",
    "user": {
        "id": "56a1f0333a65234234390d7",
        "first_name": "qqqq",
        "last_name": "wwwe",
        "created_at": "2016-01-22T09:02:43+0000",
        "updated_at": "2016-01-22T09:07:18+0000",
        "external_accounts": [],
        "confirmed_at": "2016-01-22T09:02:43+0000",
        "username": "qwe",
        "admin": "false",
        "stats": {
            "photos": {
                "total_count": 0
            },
            "storage": {
                "used": 0
            }
        },
        "photo_id": "56a1f0333a654d090d0390d8",
        "friend_counts": {
            "requests": 0,
            "friends": 0
        }
    }
},
"friend_counts": {
    "requests": 0,
    "friends": 0
}
}

basically the user which had photo uploaded during creation shows this extra info

"photo": {
    "id": "56a1f0333a654d090d0390d8",
    "filename": "userPhoto.jpg",
    "size": 25394,
    "md5": "e20f4fcadf6cde9fccfb458dd11951d4",
    "created_at": "2016-01-22T09:02:43+0000",
    "updated_at": "2016-01-22T09:02:43+0000",
    "processed": true,
    "urls": {
        "original": "https://s3-us-west-1.amazonaws.com/storage-platform.cloud.appcelerator.com/xmqh1djNEIChtQFP6d37HNH5DQNCXQoX/photos/51/d4/56a1f0333a654d090d0390d9/userPhoto_original.jpg"
    },
    "content_type": "image/jpeg",
    "user": {
        "id": "56a1f0333a65234234390d7",
        "first_name": "qqqq",
        "last_name": "wwwe",
        "created_at": "2016-01-22T09:02:43+0000",
        "updated_at": "2016-01-22T09:07:18+0000",
        "external_accounts": [],
        "confirmed_at": "2016-01-22T09:02:43+0000",
        "username": "qwe",
        "admin": "false",
        "stats": {
            "photos": {
                "total_count": 0
            },
            "storage": {
                "used": 0
            }
        },

Upvotes: 0

Views: 107

Answers (1)

Clément Blanco
Clément Blanco

Reputation: 11

I've been experiencing also that kind of problem, plus I've noticed that the images won't show up from the ArrowDB user interface (not sure if related). The API returns only an empty object when you query the model: photo: {}

I've been creating a ticket for the ArrowDB user interface https://jira.appcelerator.org/browse/API-1277.

sachinmw did you create a ticket for the initial problem yet?

A workaround could be to use the photo_id and run another separate query to retrieve the photo model but this is not good for network optimisation purposes.


EDIT

Ok after dealing with Appcelerator directly about having an empty photo: {} Object return the answer is pretty simple:

Whenever you use the query() function like Cloud.Objects.query() from ti.cloud on any ArrowDB object, there is a parameter called response_json_depth which is set to 1 by default and will only return one level of the JSON Object returned by the API.

Without touching that parameter I was seeing:

{
    "Vehicle": [
        {
            "name": "foo",
            "photo: {}
        }
    ]
}

By setting response_json_depth to 3 I managed to have:

{
    "Vehicle": [
        {
            "name": "foo",
            "photo: {
                "urls": {
                    "original": "http://bar.com"
                }
            }
        }
    ]
}

Hope that will help someone. The also applies for the Cloud.Objects.show() method for any ArrowDB object.

Upvotes: 1

Related Questions