-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Expose private File Upload V2 methods to support multiple file uploads in a single message #1376
base: master
Are you sure you want to change the base?
Expose private File Upload V2 methods to support multiple file uploads in a single message #1376
Conversation
type mockGetUploadURLExternalHttpClient struct { | ||
ResponseStatus int | ||
ResponseBody []byte | ||
} | ||
|
||
func (m *mockGetUploadURLExternalHttpClient) Do(req *http.Request) (*http.Response, error) { | ||
if req.URL.Path != "files.getUploadURLExternal" { | ||
return nil, fmt.Errorf("invalid path: %s", req.URL.Path) | ||
} | ||
|
||
return &http.Response{ | ||
StatusCode: m.ResponseStatus, | ||
Body: io.NopCloser(bytes.NewBuffer(m.ResponseBody)), | ||
}, nil | ||
} |
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.
I considered following the existing once.Do(startServer) approach for testing, but found that simply mocking Client.httpclient would be sufficient. Therefore, I decided to mock it instead.
Files: []FileSummary{{ | ||
ID: u.FileID, | ||
Title: params.Title, | ||
}}, |
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.
For CompleteUploadURLExternal, I've not only made it public but also updated its signature so that multiple fileID parameters (with IDs and titles) can be specified, aligning it more closely with Slack’s official API.
thanks for doing this. I just was revisiting a way to grab the urls so I could publish a single "gallery style" message and this probably will fix much of that by providing back the upload urls back. cheers 🙇 |
Hi, thank you for maintaining slack-go!
Currently,
UploadFileV2Context
works by sequentially calling three private methods in the following flow:Because these methods are private, developers can only upload one file per message via
UploadFileV2Context
. However, the Slack API itself supports uploading multiple files in a single message by running these steps for each file and then calling completeUploadURLExternal for all file IDs together.To unlock this functionality while still using slack-go, I’ve made the following changes in this PR:
getUploadURLExternal
andcompleteUploadExternal
publicuploadToURL
remains private for now. This method is simply a regular POST request handler, not part of Slack’s official API. Since making getUploadURLExternal and completeUploadExternal public already addresses the main use case of uploading multiple files, this might be sufficient.Thank you for considering this proposal. Being able to handle multi-file uploads in a single Slack message through slack-go would be extremely helpful. If you have any suggestions or an alternative approach, I’d love to hear them!
Related Issues
Pull Request Guidelines
These are recommendations for pull requests.
They are strictly guidelines to help manage expectations.
PR preparation
Run
make pr-prep
from the root of the repository to run formatting, linting and tests.Should this be an issue instead
API changes
Since API changes have to be maintained they undergo a more detailed review and are more likely to require changes.
Examples of API changes that do not meet guidelines: