@@ -178,14 +178,14 @@ type UploadFileV2Parameters struct {
178
178
Channel string
179
179
ThreadTimestamp string
180
180
AltTxt string
181
- SnippetText string
181
+ SnippetType string
182
182
}
183
183
184
184
type GetUploadURLExternalParameters struct {
185
- AltText string
185
+ AltTxt string
186
186
FileSize int
187
187
FileName string
188
- SnippetText string
188
+ SnippetType string
189
189
}
190
190
191
191
type GetUploadURLExternalResponse struct {
@@ -194,7 +194,7 @@ type GetUploadURLExternalResponse struct {
194
194
SlackResponse
195
195
}
196
196
197
- type uploadToURLParameters struct {
197
+ type UploadToURLParameters struct {
198
198
UploadURL string
199
199
Reader io.Reader
200
200
File string
@@ -375,15 +375,23 @@ func (api *Client) ListFilesContext(ctx context.Context, params ListFilesParamet
375
375
376
376
// UploadFile uploads a file.
377
377
//
378
- // Deprecated: Use [Client.UploadFileV2] instead. This will stop functioning on March 11, 2025.
378
+ // Deprecated: Use [Client.UploadFileV2] instead.
379
+ //
380
+ // Per Slack Changelog, specifically [https://api.slack.com/changelog#entry-march_2025_1](this entry),
381
+ // this will stop functioning on November 12, 2025.
382
+ //
379
383
// For more details, see: https://api.slack.com/methods/files.upload#markdown
380
384
func (api * Client ) UploadFile (params FileUploadParameters ) (file * File , err error ) {
381
385
return api .UploadFileContext (context .Background (), params )
382
386
}
383
387
384
388
// UploadFileContext uploads a file and setting a custom context.
385
389
//
386
- // Deprecated: Use [Client.UploadFileV2Context] instead. This will stop functioning on March 11, 2025.
390
+ // Deprecated: Use [Client.UploadFileV2Context] instead.
391
+ //
392
+ // Per Slack Changelog, specifically [https://api.slack.com/changelog#entry-march_2025_1](this entry),
393
+ // this will stop functioning on November 12, 2025.
394
+ //
387
395
// For more details, see: https://api.slack.com/methods/files.upload#markdown
388
396
func (api * Client ) UploadFileContext (ctx context.Context , params FileUploadParameters ) (file * File , err error ) {
389
397
// Test if user token is valid. This helps because client.Do doesn't like this for some reason. XXX: More
@@ -529,11 +537,11 @@ func (api *Client) GetUploadURLExternalContext(ctx context.Context, params GetUp
529
537
"filename" : {params .FileName },
530
538
"length" : {strconv .Itoa (params .FileSize )},
531
539
}
532
- if params .AltText != "" {
533
- values .Add ("initial_comment " , params .AltText )
540
+ if params .AltTxt != "" {
541
+ values .Add ("alt_txt " , params .AltTxt )
534
542
}
535
- if params .SnippetText != "" {
536
- values .Add ("thread_ts " , params .SnippetText )
543
+ if params .SnippetType != "" {
544
+ values .Add ("snippet_type " , params .SnippetType )
537
545
}
538
546
response := & GetUploadURLExternalResponse {}
539
547
err := api .postMethod (ctx , "files.getUploadURLExternal" , values , response )
@@ -544,8 +552,9 @@ func (api *Client) GetUploadURLExternalContext(ctx context.Context, params GetUp
544
552
return response , response .Err ()
545
553
}
546
554
547
- // uploadToURL uploads the file to the provided URL using post method
548
- func (api * Client ) uploadToURL (ctx context.Context , params uploadToURLParameters ) (err error ) {
555
+ // UploadToURL uploads the file to the provided URL using post method
556
+ // This is not a Slack API method, but a helper function to upload files to the URL
557
+ func (api * Client ) UploadToURL (ctx context.Context , params UploadToURLParameters ) (err error ) {
549
558
values := url.Values {}
550
559
if params .Content != "" {
551
560
contentReader := strings .NewReader (params .Content )
@@ -565,6 +574,7 @@ func (api *Client) CompleteUploadExternalContext(ctx context.Context, params Com
565
574
if err != nil {
566
575
return nil , err
567
576
}
577
+
568
578
values := url.Values {
569
579
"token" : {api .token },
570
580
"files" : {string (filesBytes )},
@@ -611,16 +621,16 @@ func (api *Client) UploadFileV2Context(ctx context.Context, params UploadFileV2P
611
621
}
612
622
613
623
u , err := api .GetUploadURLExternalContext (ctx , GetUploadURLExternalParameters {
614
- AltText : params .AltTxt ,
624
+ AltTxt : params .AltTxt ,
615
625
FileName : params .Filename ,
616
626
FileSize : params .FileSize ,
617
- SnippetText : params .SnippetText ,
627
+ SnippetType : params .SnippetType ,
618
628
})
619
629
if err != nil {
620
630
return nil , err
621
631
}
622
632
623
- err = api .uploadToURL (ctx , uploadToURLParameters {
633
+ err = api .UploadToURL (ctx , UploadToURLParameters {
624
634
UploadURL : u .UploadURL ,
625
635
Reader : params .Reader ,
626
636
File : params .File ,
0 commit comments