Anonymous
Файл не показывает канал Slack
Сообщение
Anonymous » 13 июл 2025, 00:10
Я использую node.js, я хочу отправить файл в Slack, я использую функции getUploadUrlexternal и FulthuploAdexternal функции. Мое первоначальное сообщение (инцидент обнаружено .....) отображался в канале, а файл также успешно хранился, так как я вижу URL_Private в журналах, но не отображал файл, который я хранил, в упомянутом канале, ниже мой код. < /P>
Код: Выделить всё
const messageRes = await web.chat.postMessage({
channel: "#jr-developers",
text: "🚨 Incident detected! Please check the attached report below.",
});
console.log("Message sent:", messageRes.ts);
// console.log(messageRes);
// Step 3: Upload file content to the URL using axios
const fileName = "continent.csv";
const fileBuffer = fs.readFileSync(fileName);
const fileLength = fileBuffer.length;
// Step 2: Get upload URL from Slack
const uploadURLRes = await web.files.getUploadURLExternal({
filename: fileName,
length: fileLength,
});
const uploadUrl = uploadURLRes.upload_url;
const fileId = uploadURLRes.file_id;
console.log("Received upload URL from Slack.", uploadUrl, fileId);
await axios.put(uploadUrl, fileBuffer, {
headers: {
"Content-Type": "application/octet-stream",
"Content-Length": fileLength,
},
});
console.log("File uploaded to Slack storage.");
// console.log(axiosRes);
// Step 4: Complete the upload and share in thread
const res = await web.files.completeUploadExternal({
files: [
{
id: fileId,
title: "slack-test",
},
],
channel_id: messageRes.channel,
thread_ts: messageRes.ts,
});
console.log("File attached to thread successfully.");
Это журналы,
{
ok: true,
files: [
{
id: 'F0****J3A',
created: ***,
timestamp: ***,
name: 'continent.csv',
title: 'slack-test',
mimetype: '',
filetype: '',
pretty_type: '',
user: '***',
user_team: '***',
editable: false,
size: 86,
mode: 'hosted',
is_external: false,
external_type: '',
is_public: false,
public_url_shared: false,
display_as_bot: false,
username: '',
url_private: '
https://files.slack.com/files-pri******continent.csv ',
url_private_download: '
https://files.slack.com/files-pri*****d ... tinent.csv ',
media_display_type: 'unknown',
permalink: '
https://profitops.slack.com/files****continent.csv ',
permalink_public: '
https://slack-files.com/ *****',
comments_count: 0,
is_starred: false,
shares: {},
channels: [],
groups: [],
ims: [],
has_more_shares: false,
has_rich_preview: false,
file_access: 'visible'
}
],
response_metadata: {
scopes: [
'identify', 'channels:history',
'groups:history', 'im:history',
'mpim:history', 'channels:read',
'groups:read', 'im:read',
'mpim:read', 'users:read',
'channels:write', 'chat:write',
'files:write', 'groups:write',
'im:write', 'mpim:write',
'identity.basic', 'identity.email',
'identity.avatar'
],
acceptedScopes: [ 'files:write' ]
}
}
File attached to thread successfully.
< /code>
Я все проверил. Пожалуйста, помогите.
Подробнее здесь:
https://stackoverflow.com/questions/796 ... ck-channel
1752354642
Anonymous
Я использую node.js, я хочу отправить файл в Slack, я использую функции getUploadUrlexternal и FulthuploAdexternal функции. Мое первоначальное сообщение (инцидент обнаружено .....) отображался в канале, а файл также успешно хранился, так как я вижу URL_Private в журналах, но не отображал файл, который я хранил, в упомянутом канале, ниже мой код. < /P> [code]const messageRes = await web.chat.postMessage({ channel: "#jr-developers", text: "🚨 Incident detected! Please check the attached report below.", }); console.log("Message sent:", messageRes.ts); // console.log(messageRes); // Step 3: Upload file content to the URL using axios const fileName = "continent.csv"; const fileBuffer = fs.readFileSync(fileName); const fileLength = fileBuffer.length; // Step 2: Get upload URL from Slack const uploadURLRes = await web.files.getUploadURLExternal({ filename: fileName, length: fileLength, }); const uploadUrl = uploadURLRes.upload_url; const fileId = uploadURLRes.file_id; console.log("Received upload URL from Slack.", uploadUrl, fileId); await axios.put(uploadUrl, fileBuffer, { headers: { "Content-Type": "application/octet-stream", "Content-Length": fileLength, }, }); console.log("File uploaded to Slack storage."); // console.log(axiosRes); // Step 4: Complete the upload and share in thread const res = await web.files.completeUploadExternal({ files: [ { id: fileId, title: "slack-test", }, ], channel_id: messageRes.channel, thread_ts: messageRes.ts, }); console.log("File attached to thread successfully."); [/code] [b] Это журналы, [/b] { ok: true, files: [ { id: 'F0****J3A', created: ***, timestamp: ***, name: 'continent.csv', title: 'slack-test', mimetype: '', filetype: '', pretty_type: '', user: '***', user_team: '***', editable: false, size: 86, mode: 'hosted', is_external: false, external_type: '', is_public: false, public_url_shared: false, display_as_bot: false, username: '', url_private: 'https://files.slack.com/files-pri******continent.csv', url_private_download: 'https://files.slack.com/files-pri*****download/continent.csv', media_display_type: 'unknown', permalink: 'https://profitops.slack.com/files****continent.csv', permalink_public: 'https://slack-files.com/*****', comments_count: 0, is_starred: false, shares: {}, channels: [], groups: [], ims: [], has_more_shares: false, has_rich_preview: false, file_access: 'visible' } ], response_metadata: { scopes: [ 'identify', 'channels:history', 'groups:history', 'im:history', 'mpim:history', 'channels:read', 'groups:read', 'im:read', 'mpim:read', 'users:read', 'channels:write', 'chat:write', 'files:write', 'groups:write', 'im:write', 'mpim:write', 'identity.basic', 'identity.email', 'identity.avatar' ], acceptedScopes: [ 'files:write' ] } } File attached to thread successfully. < /code> [b] Я все проверил. Пожалуйста, помогите. [/b] Подробнее здесь: [url]https://stackoverflow.com/questions/79699573/file-is-not-showing-the-the-slack-channel[/url]