Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-upload-image-alt-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slack/web-api": patch
---

fix: image alt text passed to `files.uploadV2` is now saved. Before, it was sent as `alt_text`, which Slack ignores. Deprecate `alt_text` in `files.getUploadURLExternal` arguments in favor of `alt_txt` ([#2788](https://github.com/slackapi/node-slack-sdk/issues/2788))
3 changes: 2 additions & 1 deletion packages/web-api/src/WebClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ describe('WebClient', () => {

it('uploads multiple files', async () => {
const scope = nock('https://slack.com')
.post('/api/files.getUploadURLExternal', { filename: 'test-png.png', length: 55292 })
.post('/api/files.getUploadURLExternal', { filename: 'test-png.png', length: 55292, alt_txt: 'A test image' })
.reply(200, {
ok: true,
file_id: 'F0000000001',
Expand Down Expand Up @@ -1717,6 +1717,7 @@ describe('WebClient', () => {
{
file: fs.createReadStream('./test/fixtures/test-png.png'),
filename: 'test-png.png',
alt_text: 'A test image',
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion packages/web-api/src/WebClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class WebClient extends Methods {
const options = {
filename: upload.filename,
length: upload.length,
alt_text: upload.alt_text,
alt_txt: upload.alt_text,
snippet_type: upload.snippet_type,
} as FilesGetUploadURLExternalArguments;
if ('token' in upload) {
Expand Down
2 changes: 2 additions & 0 deletions packages/web-api/src/types/request/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export interface FilesGetUploadURLExternalArguments extends TokenOverridable {
/** @description Size in bytes of the file being uploaded. */
length: number;
/** @description Description of image for screen-reader. */
alt_txt?: string;
/** @deprecated Slack does not use this. Use `alt_txt`. */
alt_text?: string;
/** @description Syntax type of the snippet being uploaded. E.g. `python`. */
snippet_type?: string;
Expand Down