Start a new topic

Upload a FileRefernce to the user Collection


is there any difference between uploading a fileReference (image in this case) to a data-collection or the user-collection?

Saving a fileRef and an id to the user just save this two variables inside the (in this case) "avatar" object in the user-Collection.

On my data-collection (same code) there are also values for the download-url, size, _kmd stuff etc.

I need that addional data inside the avatar of the user, too - so how can i achieve this?


				'avatar' : {
					_type : 'KinveyFile',
					_id : file._id
				console.debug("Image ::: assigned to User");

Doing like above


Best, Nico



Cause i don't want to create an ugly workaround for this.

Best, Nico

Hi Nico,

There isn’t difference between saving to any data collection or the user collection.

If I understand this correctly, you are already saving the avatar related data in your “data collection” and then you also want to update some part of that avatar metadata (file id) in the user collection?
If that is the case, a suggestion is : You should implement the “OnPostSave”collection hook for your data collection and in that server side logic you can update the current user’s avatar info..So whenever data is saved into your “data collection”, then OnPostSave() hook will be called where you can get the avatar file related data and update in the user collection for the current user.

Here is the more information about writing Busines Logic:

If I have misunderstood this, please provide more details so that we will be able to help you.


Kinvey Support


thanks for your answer!

I'll try to be more clear:

My situation is, that i have profil-Images ("avatar") for both, users and groups, users can be member of.

The difference is, that kinvey seems to handle the User Collection a little bit different to a normal "data collection".

Saving the fileReference to the datacollection ("squads" in this case) , result in an object containing the downloadURL to the file and all other kinds of informations. (Which is great)

Saving the fileReference( same client code) to the user-Collection results in something like this:

As you can see, there is only the fileID and none of the addional informations, that are automaticly added, saving it to a normal datacollection.

So my workaround idea is, after the user saves the file as his/her profil image, i call the download url and stuff by myself, and update the object, too. So the main question is (i guess) why do you handle that collections differently in this case, cause to me it doesn't make sense. :P

best, Nico


Okay, yes. The persisting of a KCSFile object to users collection is a special case and seems by design. I will try getting more information about this from the development team. You have also properly handled the scenario where you also want to save the downloadURL to user’s collection.



Thanks, I'm looking forward to more infos from you.



cause there are no more informationen about this, i will create a workaround for that. Maybe you can consider to re-think this special behavior in one of the next updates or, at least, comment it inside the documentation.

Best, Nico


Any new information on resolving KinveyFile refs with the user collection?

Visual user context is becoming a very common UI feature (look at my name and profile image above this post). Currently I have to collect the user and then run separate code to go and get the user image and apply it. 

In the case of something like a portal where we show a logged in user load can be delayed but up to 1000ms (depending on Kinvey response times) just to set the user's avatar. 



Login or Signup to post a comment