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

feat(api): UploadBinaryFile support uploads binary file #71

Closed
wants to merge 1 commit into from

Conversation

wahwahid
Copy link

We usually need to upload system generated virtual files that contains dynamic data.

@crispgm
Copy link
Contributor

crispgm commented Mar 22, 2024

Looks good.

Would you mind showing me the document from lark platform? I want to know the usage. Thanks.

@wahwahid
Copy link
Author

Actually UploadBinaryFile share same API with UploadFile.
https://open.feishu.cn/document/server-docs/im-v1/file/create

The differentiation when UploadFile lookup a file based on path provided in the argument then load the content, UploadBinaryFile retrieve file content via io.Reader directly.

@crispgm
Copy link
Contributor

crispgm commented Mar 22, 2024

Actually UploadBinaryFile share same API with UploadFile. https://open.feishu.cn/document/server-docs/im-v1/file/create

The differentiation when UploadFile lookup a file based on path provided in the argument then load the content, UploadBinaryFile retrieve file content via io.Reader directly.

I think it not necessary to create a new method. Maybe just add a parameter in the request?

@wahwahid
Copy link
Author

wahwahid commented Mar 22, 2024

I was thinking about that too, but i follow what UploadImage & UploadImageObject do.
They also share same API but have different input.
What do you think, wasn't this PR follow the project approach to have isolated and clear method ?

If change to one method with additional parameter, i have a question.
How we decide between path / binary ?

  1. Make the reader pointer, check the reader, use path when the reader nil or
  2. Check the path, use binary when the path empty ?

But, what happen if both empty ?

  1. Return error from our package side ?

@crispgm
Copy link
Contributor

crispgm commented Mar 22, 2024

I was thinking about that too, but i follow what UploadImage & UploadImageObject do. They also share same API but have different input. What do you think, wasn't this PR follow the project approach to have isolated and clear method ?

If change to one method with additional parameter, i have a question. How we decide between path / binary ?

1. Make the reader pointer, check the reader, use path when the reader nil or

2. Check the path, use binary when the path empty ?

But, what happen if both empty ?

1. Return error from our package side ?

The UploadImageObject is an old-school method, which was not reviewed carefully and then migrated from in-house repo to GitHub. We may also remove UploadImageObject then.

Maybe change both into pointers and check which is not nil.

@wahwahid
Copy link
Author

Hi @crispgm please check another PR related to changes here: #72

@crispgm crispgm closed this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants