-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added new FileUploadV2 function to avoid server side file timeouts #1130
Added new FileUploadV2 function to avoid server side file timeouts #1130
Conversation
@kanata2 making a PR for the first time, how do I request your review/add label? |
@sarthakkothari Sorry for delay. Will review within a few days. 🙏 |
} | ||
|
||
// UploadFileV2 uploads file to a given slack channel using 3 steps - | ||
// 1. Get an upload URL using files.getUploadURLExternal API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 1. Get an upload URL using files.getUploadURLExternal API | |
// 1. Get an upload URL using files.getUploadURLExternal API |
@@ -145,6 +146,44 @@ type ListFilesParameters struct { | |||
Cursor string | |||
} | |||
|
|||
type FileUploadV2Parameters struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO] Prefer UploadFileV2Parameters
. It would be easier to use if aligned with the method name.
SlackResponse | ||
} | ||
|
||
type uploadToExternalParams struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uploadToURLParameters
?
@@ -416,3 +455,119 @@ func (api *Client) ShareFilePublicURLContext(ctx context.Context, fileID string) | |||
} | |||
return &response.File, response.Comments, &response.Paging, nil | |||
} | |||
|
|||
// getUploadURLExternal gets a URL and fileID from slack which can later be used to upload a file | |||
func (api *Client) getUploadURLExternal(ctx context.Context, fileSize int, fileName, altText, snippetText string) (*getUploadURLExternalResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defining struct since there are many parameters?
} | ||
|
||
// completeUploadExternal once files are uploaded, this completes the upload and shares it to the specified channel | ||
func (api *Client) completeUploadExternal(ctx context.Context, fileID string, params FileUploadV2Parameters) (file *completeUploadExternalResponse, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is preferable to define struct instead of using FileUploadV2Prameters
.
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/slack-go/slack](https://togithub.com/slack-go/slack) | require | patch | `v0.12.0` -> `v0.12.1` | --- ### Release Notes <details> <summary>slack-go/slack</summary> ### [`v0.12.1`](https://togithub.com/slack-go/slack/releases/tag/v0.12.1) [Compare Source](https://togithub.com/slack-go/slack/compare/v0.12.0...v0.12.1) #### What's Changed ##### Enhancements - Add FileUploadV2 function to avoid server side file timeouts by [@​kanata2](https://togithub.com/kanata2) in [https://github.com/slack-go/slack/pull/1148](https://togithub.com/slack-go/slack/pull/1148) - Added new FileUploadV2 function to avoid server side file timeouts by [@​sarthakkothari](https://togithub.com/sarthakkothari) in [https://github.com/slack-go/slack/pull/1130](https://togithub.com/slack-go/slack/pull/1130) #### New Contributors - [@​sarthakkothari](https://togithub.com/sarthakkothari) made their first contribution in [https://github.com/slack-go/slack/pull/1130](https://togithub.com/slack-go/slack/pull/1130) **Full Changelog**: slack-go/slack@v0.12.0...v0.12.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 3am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC40Mi4wIiwidXBkYXRlZEluVmVyIjoiMzQuNDIuMCJ9-->
Linking issue
This PR solves for - #1108
Implements the methods suggested in - https://github.com/slackapi/python-slack-sdk/releases/tag/v3.19.0
Need to account for nil interface because slack doesn't give
SlackResponse
or any json response for that matter when uploading file via post to GetUploadURLExternal's UploadURL