Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello!
I've just started using the Dropbox Python API, but am a bit confused on how to add custom metadata to new or exists files.
I've tried to defined my own PropertyGroup with the data stored in a PropertyField (as shown in the code below). However, passing this as a parameter of dbx.files_upload() causes the process to freezes up. Should the template_id of the property group be defined differently?
data = dropbox.file_properties.PropertyField('foo', 'bar') my_property_group = dropbox.file_properties.PropertyGroup() my_property_group .template_id = '/|test_template' my_property_group .fields = [data] with open(r'C:\test_file.txt', "rb") as f: dbx.files_upload(f.read(), '/test_file.txt', mute = True, property_groups=[my_property_group ])
Any help on this would be much appreciated!
Thanks for following up. I'm glad to hear you already sorted most of this out.
Thanks for the report. I'll be happy to help with this, but I could use a few points of clarification:
I also notice that you're not using the return value of 'dbx.files_upload'. You may want to print or save that value somewhere for reference. If the call succeeds, it will contain the metadata of the uploaded file.
Thanks for pointing a few things out that I seem to have overlooked. The freezing up, ended up being due to wrong formatting and an incorrect unique id for the custom string template - now sourced correctly using the following code:
template = dropbox.file_properties.PropertyFieldTemplate(name="MyTemplate", description="description",type=dropbox.file_properties.PropertyType.string) my_template_id = dbx.file_properties_templates_add_for_user("MyTemplate","description",[template]).template_id data = dropbox.file_properties.PropertyField(name='MyTemplate', value='foobar')
Thanks for following up. I'm glad to hear you already sorted most of this out.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
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!