Skip to content

Commit

Permalink
More improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakkothari committed Dec 3, 2022
1 parent 5b488b4 commit 7c39b55
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions files.go
Expand Up @@ -459,10 +459,10 @@ func (api *Client) ShareFilePublicURLContext(ctx context.Context, fileID string)
// 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) {
values := url.Values{
"token": {api.token},
"token": {api.token},
"filename": {fileName},
"length": {strconv.Itoa(fileSize)},
}
values.Add("filename", fileName)
values.Add("length", strconv.Itoa(fileSize))
if altText != "" {
values.Add("initial_comment", altText)
}
Expand Down Expand Up @@ -495,17 +495,16 @@ func (api *Client) uploadToURL(ctx context.Context, params uploadToExternalParam

// 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) {
values := url.Values{
"token": {api.token},
}

request := []FileSummary{{ID: fileID, Title: params.Title}}
requestBytes, err := json.Marshal(request)
if err != nil {
return nil, err
}
values.Add("files", string(requestBytes))
values.Add("channel_id", params.Channel)
values := url.Values{
"token": {api.token},
"files": {string(requestBytes)},
"channel_id": {params.Channel},
}

if params.InitialComment != "" {
values.Add("initial_comment", params.InitialComment)
Expand Down

0 comments on commit 7c39b55

Please sign in to comment.