Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
cgeeklucky
8 years agoExplorer | Level 4
File properties
Can anyone tell me why exactly I need to create a team to add file attributes to a file? All I want to do is add a single attribute called "FileParentIdentifier" (which will hold a string value i.e ...
- 8 years agoA "team" refers to a Dropbox Business level collection of accounts. If you're interested, you can find more information here:
https://www.dropbox.com/business
Note that you don't need a Dropbox Business team to use the file properties functionality on the Dropbox API though:
https://www.dropbox.com/developers/documentation/http/documentation#file_properties
You can use a "full Dropbox" app to create templates that you can apply to files, whether or not the linked account is part of a Business team. (There is also a concept of templates owned by teams, but that is not required.)
So, in short, you can:
1. Register a full Dropbox app, if you haven't already: https://www.dropbox.com/developers/apps/create
2. Connect a user using the OAuth flow: https://www.dropbox.com/developers/reference/oauth-guide
3. Create a template using/2/file_properties/templates/add_for_user : https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-add_for_user
4. Add file properties for your template to any number of files using /2/file_properties/properties/add: https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-add
Greg-DB
Dropbox Community Moderator
8 years agoIt looks like the issue is that you're using a different field name when creating the template and then when trying to apply it later. I.e.:
let template = FileProperties.PropertyFieldTemplate(name: "FileTemplate", description_: "File's Custom Properties Here", type: .string_)
But then:
let field = FileProperties.PropertyField(name: "ParentFolderID", value: "123456")
That name "ParentFolderID" should be "FileTemplate" (or whatever you want it to be, as long as you're consistent).
cgeeklucky
8 years agoExplorer | Level 4
So template itself is custom attribute. (I was dumb to understand that).
I corrected the code and uploaded a file, uploaded with no error. However, propertyGroups from metadata (upload response) is nil.
response from uploading file looks like this.
{
"client_modified" = "2018-08-03T04:34:16Z";
"content_hash" = fea824f165374189797de317f75058467ddbec03b95755eee30e9612b6c6929e;
id = "id:vPJIFqqKgdAAAAAAAAABiQ";
name = "153327085668483.png";
"path_display" = "/AppFolder/153327085668483.png";
"path_lower" = "/appfolder/153327085668483.png";
rev = 2feb83ead00;
"server_modified" = "2018-08-03T04:34:29Z";
size = 250930;
}
When I tried to print metadata?.propertyGroups, it returns nil :(
One more confusion, Is template id constant ? ( Can I store the templateID in my realm database, so that I don't have to call
templatesListForUser method again and again )
- cgeeklucky8 years agoExplorer | Level 4
It looks like property groups are added successfully , but it isn't showing in metadata of uploaded file.
I tried to get metadata of same file using below method.
client?.files.getMetadata(path: "/Ninja/153327085668483.png", includeMediaInfo: true, includeDeleted: false, includeHasExplicitSharedMembers: false, includePropertyGroups: FileProperties.TemplateFilterBase.filterSome(["ptid:LNRGA28Fu5AAAAAAAAAAtg"])).response(completionHandler: { (meta, error) in print(meta) })response
{ "client_modified" = "2018-08-03T04:34:16Z"; "content_hash" = fea824f165374189797de317f75058467ddbec03b95755eee30e9612b6c6929e; id = "id:vPJIFqqKgdAAAAAAAAABiQ"; name = "153327085668483.png"; "path_display" = "/Ninja/153327085668483.png"; "path_lower" = "/ninja/153327085668483.png"; "property_groups" = ( { fields = ( { name = ParentFolderID; value = A123456; } ); "template_id" = "ptid:LNRGA28Fu5AAAAAAAAAAtg"; } ); rev = 2feb83ead00; "server_modified" = "2018-08-03T04:34:29Z"; size = 250930; }Thank you Greg for your replies :)
- Greg-DB8 years ago
Dropbox Community Moderator
Yes, that's expected. The property values won't be returned in the metadata from the upload itself. A successful response as you're receiving does indicate that is was successfully submitted though.
You need to call and explicitly request the property values, as you have done.
And yes, the template ID for a given template doesn't change, so you can and should store and re-use it.- cgeeklucky8 years agoExplorer | Level 4Okay... Thank you. :)
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!