Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hs.resource(resource_id).files.metadata(file_id, f["metadata"]) Does Not work for GenericFileType #99

Open
zhiyuli opened this issue Jan 11, 2019 · 9 comments
Assignees

Comments

@zhiyuli
Copy link
Member

zhiyuli commented Jan 11, 2019

hs.resource(resource_id).files.metadata(file_id, f["metadata"])
Works for ReferencedFile,
But it Does Not work for GernericFileType

@sblack-usu sblack-usu self-assigned this Jan 14, 2019
@sblack-usu
Copy link
Contributor

What do you mean by generic file type? Pretty sure a ReferenceFile uses GenericLogicalFile. A regular file does not have a logical file type attached to it, so if you want to add metadata to a file you'll have to first set it as the type. You can do that in the UI with the dropdown box and selecting "add metadata to file":
image

To do this in the api, do smething like this:

options = {
             "file_path": "mailchimp.txt",
             "hs_file_type": "Generic"
          }
hs.resource(resource_id).functions.set_file_type(options)

@zhiyuli
Copy link
Member Author

zhiyuli commented Jan 16, 2019

@sblack-usu
is every file uploaded to CompositeResource a GenericLogicalFile by default?

@zhiyuli
Copy link
Member Author

zhiyuli commented Jan 16, 2019

@sblack-usu
I just want to add metadata to a GenericLogicalFile file via api:
Should I set file type first and then add metadata, like

step 1: set file to GenericLogicalFile

options = {
"file_path": "mailchimp.txt",
"hs_file_type": "Generic"
}
hs.resource(resource_id).functions.set_file_type(options)

step 2: find file_id

step 3: add metadata to file

f_metadata = {....}
hs.resource(resource_id).files.metadata(file_id, f_metadata

@zhiyuli
Copy link
Member Author

zhiyuli commented Jan 16, 2019

@sblack-usu
Also I think it is better to standardize the use of filename and file_id.
Currently some endpoints need filename but other need file_id....

@sblack-usu
Copy link
Contributor

no, files don't have any logical file by default unless they're recognized as an aggregation. Apologies for the inconsistencies between file_id an dfile_path... this was inherited. I'm in favor of ditching file_ids completely. I can update metadata to take the path in this ticket as well. For backwards compatibility, I'll leave the file_id in there as well.

@zhiyuli
Copy link
Member Author

zhiyuli commented Jan 23, 2019

@sblack-usu
also in some cases, HS will rename uploaded files. one case I found was "my file.txt" got changed to "my_file.txt".
if we choose to use filename as the identifier, the uploading/creation rest api should return the new filename HS saved, or return both file_id and filename.

@sblack-usu
Copy link
Contributor

yeah, that's some functionality that came in to standardize file names. I voted for just blocking names with spaces, but it was decided we would change " " to "_". I agree it should return the resulting file name.

@ghost ghost assigned zhiyuli and ghost Feb 13, 2019
@zhiyuli
Copy link
Member Author

zhiyuli commented Feb 13, 2019

step 1: set file to GenericLogicalFile doesnt work in HS RC1.19 + Client 1.3.1

options = {
"file_path": "mailchimp.txt",
"hs_file_type": "Generic"
}
hs.resource(resource_id).functions.set_file_type(options)

@zhiyuli
Copy link
Member Author

zhiyuli commented Feb 13, 2019

fixed by changing "Generic" to "SingleFile". Thanks @sblack-usu
options = {
"file_path": f["file_name"],
"hs_file_type": "SingleFile"
}
hs.resource(hs_id).functions.set_file_type(options)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants