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

Added new FileUploadV2 function to avoid server side file timeouts #1130

Merged
merged 4 commits into from Dec 20, 2022

Conversation

sarthakkothari
Copy link
Contributor

@sarthakkothari sarthakkothari commented Nov 21, 2022

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

@sarthakkothari
Copy link
Contributor Author

@kanata2 making a PR for the first time, how do I request your review/add label?

@kanata2
Copy link
Member

kanata2 commented Dec 2, 2022

@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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 {
Copy link
Member

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 {
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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.

@kanata2 kanata2 merged commit 7c39b55 into slack-go:master Dec 20, 2022
kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Jan 1, 2023
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 [@&#8203;kanata2](https://togithub.com/kanata2) in [slack-go/slack#1148
    -   Added new FileUploadV2 function to avoid server side file timeouts by [@&#8203;sarthakkothari](https://togithub.com/sarthakkothari) in [slack-go/slack#1130

#### New Contributors

-   [@&#8203;sarthakkothari](https://togithub.com/sarthakkothari) made their first contribution in [slack-go/slack#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-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants