Notifications
Clear all

User files

(@punchey)
Eminent Member Registered

I have a few questions regarding user files:

  1. I see that there are sharing flags you can assign to a UserFile. So I assume this means that files are somehow discoverable by other users? What methods can you use to search for and find shared user files? Can you search based on metadata for the file?
  2. It looks like the only place for storing data in a UserFile is the customData field? Or is there another member of UserFile which holds the data of the file itself, and customData is just intended to store metadata?
  3. If all data must exist in customData, if I need to store 30kb of binary data in the file but also need searchable string metadata inside customData, would I need to do something like Base64 encode the binary blob as an entry into the customData hashtable?

Thank you!

ReplyQuote
Topic starter Posted : 29/04/2020 5:13 am
(@skaredcreations)
Prominent Member Admin

Here is:

  1. You can actually get the files of a user and use the parameter includeShared to include the files shared with him (that are the files with sharingType Everybody or Friends, read here); there isn't currently a defined advanced search by customData, but if you need this feature then I can add it to my TODO list for a future update
  2. The property customData is to store your own custom properties just like customData in the User class, the file content is sent to the method Update as byte array and stored physically in the filesystem and not on database, then you can download it through the WWW Unity class using the property url (or just use the accessory method Download that will give you the byte array in the callback, read the above URL)
  3. You could also store a Base64 encoded string for binary data, but I would personally avoid to store an encoded binary data if that's too large because the database would easily grow up very much with hundreds or thousands users, instead I'd eventually create another user file for the binary and store its id as a customData key in the other one (small trick to avoid large data in the database and Base64 encoding/decoding performance hits)

 

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 29/04/2020 7:37 pm
(@punchey)
Eminent Member Registered

Thanks for the reply!

  1. Yes, my thought is to use publicly shared UserFiles as user-generated content that can be publicly browsed and searched without knowing who the owning user is. So if there's a way to allow aggregating and searching those based on some metadata or something, that would be perfect.
  2. I see, so to clarify, the binary data is separate from the customData field? Meaning I can use customData as metadata, etc?
ReplyQuote
Topic starter Posted : 29/04/2020 9:15 pm
(@skaredcreations)
Prominent Member Admin
Posted by: @punchey

I see, so to clarify, the binary data is separate from the customData field? Meaning I can use customData as metadata, etc?

Yes that's correct, the file content is not stored in customData but on the filesystem (in a folder hierarchy under /upload) and downloadable through the property url.

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 30/04/2020 11:40 am
(@punchey)
Eminent Member Registered

@skaredcreations ah! I see! That's perfect!  Because I have plenty of storage in my web hosting plan, but a lot less storage allowance in my MySQL DB.

 

Thanks so much. And let me know if you think of a way to make shared files discoverable / searchable by other users.

ReplyQuote
Topic starter Posted : 30/04/2020 7:50 pm
(@punchey)
Eminent Member Registered

Would SearchCustomData() be useful here to search for metadata in the UserFile.customData field?

ReplyQuote
Topic starter Posted : 01/05/2020 1:42 am
(@skaredcreations)
Prominent Member Admin

SearchCustomData Is used in User search, so I’ll probably use the same technique for UserFile. Though it will require to move customData from the UserFile table into its own in database, just like it’s for User customData, so I also have to create a script to migrate the current data.

I’ll begin to work on this after the next incoming update will be released.

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 01/05/2020 11:45 am
Punchey liked
(@punchey)
Eminent Member Registered

@skaredcreations I sent you a DM when you get a chance. Thanks!

ReplyQuote
Topic starter Posted : 08/05/2020 9:49 pm
Share: