V
V
vsekov2019-12-25 11:55:40
API
vsekov, 2019-12-25 11:55:40

How to send a document to VK with the desired extension?

To upload a document to a group, I use the following code:

async function uploadDoc(g_Id, srs, ttle)
{
    return u_vk.upload.document({
        group_id: g_Id,
        source: srs,
        title: ttle

      })
      .then((doc) => {
        console.log('Success upload', doc);
        return doc;
      })
      .catch(console.error);
}

await uploadDoc(publicId, __dirname + '\\' + msg.senderId + '.cpp', msg.senderId + '.cpp');

As a result, a downloaded file appears with the name that I specified, but when downloading, the extension changes to '*.dat'.
r7kKekBOMZU.jpg
azsDGCL7Q04.jpg
How can I send a document to a VK group with the desired extension ('*.cpp)?
Additional question: is it possible to hide uploaded documents from group subscribers?
To connect to the API, I use the 'vk-io' library.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2019-12-25
@vsekov

async function uploadDoc(g_Id, srs, ttle)
{
    return u_vk.upload.document({
        group_id: g_Id,
        source: {
            value: srs,
            filename: ttle
        },
        title: ttle

      })
      .then((doc) => {
        console.log('Success upload', doc);
        return doc;
      })
      .catch(console.error);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question