title: Send a pdf file using telegram bot api
body: <p>i am trying to send a pdf file using the url of the file and using the method "sendDocument", the problem is that i cant access the file directly because of the server where its stored. I tried to use the answer provided in this post:
  <a href="https://stackoverflow.com/questions/48586522/readfilesync-from-an-url-for-twitter-media-node-js">readFileSync from an URL for Twitter media - node.js</a></p>
  
  <p>It works, but the file is send as "file.doc". If i change the extension to pdf, it is the correct file. Is there any extra step i need to do to send the file with the correct name and extension, or is there another way i can achieve what i need?</p>
  
  <p><strong><em>EDIT:</em></strong> The code i am using to get the pdf looks exactly like the code in the anwser of the post i provided:</p>
  
  <pre><code>function getImage(url, callback) {
  https.get(url, res =&gt; {
      // Initialise an array
      const bufs = [];
  
      // Add the data to the buffer collection
      res.on('data', function (chunk) {
          bufs.push(chunk)
      });
  
      // This signifies the end of a request
      res.on('end', function () {
          // We can join all of the 'chunks' of the image together
          const data = Buffer.concat(bufs);
  
          // Then we can call our callback.
          callback(null, data);
      });
  })
  // Inform the callback of the error.
  .on('error', callback);
  }
  </code></pre>
  
  <p>To send the file i use something like this:</p>
  
  <pre><code>getImage(url, function(err, data){
      if(err){
          throw new Error(err);
      }
  
      bot.sendDocument(
          msg.chat.id,
          data,
      );
  })
  </code></pre>