core: Files are not getting stored or maybe I can't locate them...
I’ve a problem that I can’t see any files, photos, etc sent from my mobile phone.
To figure out where the files should be located I used this code in hook.php
echo $telegram->getUploadPath();
Output from Browser: /var/www/website.tld/mybot/php-telegram-bot/src/…/Upload
So the location for uploaded files should be there /var/www/website.tld/mybot/php-telegram-bot/src/Upload right?
All the folder permissions should be correct. Webserver (Nginx) runs as www-data.
# ls -l
total 1900
-rwxrwxr-- 1 root www-data 120414 Jun 8 20:35 mybot_debug.log
-rwxrwxr-- 1 root www-data 7070 Jun 8 20:35 mybot_error.log
-rwxrwxr-- 1 root www-data 25560 Jun 8 20:37 mybot_update.log
drwxrwxr-- 2 root www-data 4096 Jun 6 22:34 commands
-rwxrwxr-- 1 root www-data 1049 Jun 7 19:34 composer.json
-rwxrwxr-- 1 root www-data 41755 Jun 5 20:27 composer.lock
-rwxrwxr-- 1 root www-data 1640247 Jun 5 20:44 composer.phar
-rwxrwxr-- 1 root www-data 1589 Jun 5 20:27 CONTRIBUTING.md
-rwxrwxr-- 1 root www-data 712 Jun 5 20:27 CREDITS
drwxrwxr-- 2 root www-data 4096 Jun 5 20:27 doc
drwxrwxr-- 3 root www-data 4096 Jun 5 20:27 examples
-rwxrwxr-- 1 root www-data 3561 Jun 8 20:35 hook.php
-rwxrwxr-- 1 root www-data 1175 Jun 5 20:27 LICENSE.md
-rwxrwxr-- 1 root www-data 4149 Jun 5 20:27 phpcs.xml
-rwxrwxr-- 1 root www-data 1519 Jun 5 20:27 phpunit.xml.dist
-rwxrwxr-- 1 root www-data 17323 Jun 5 20:27 README.md
-rwxrwxr-- 1 root www-data 650 Jun 5 22:38 set.php
drwxrwxr-- 5 root www-data 4096 Jun 5 20:27 src
drwxrwxr-- 3 root www-data 4096 Jun 5 20:27 tests
drwxrwxr-- 2 root www-data 4096 Jun 8 20:30 Upload
drwxrwxr-- 2 root www-data 4096 Jun 5 20:27 utils
drwxrwxr-- 13 root www-data 4096 Jun 7 19:34 vendor'
root@30393:/var/www/website.tld/mybot/php-telegram-bot/src# ls -l
total 136
-rwxrwxr-- 1 root www-data 2600 Jun 5 20:27 BotanDB.php
-rwxrwxr-- 1 root www-data 5665 Jun 5 20:27 Botan.php
drwxrwxr-- 5 root www-data 4096 Jun 5 20:27 Commands
-rwxrwxr-- 1 root www-data 5375 Jun 5 20:27 ConversationDB.php
-rwxrwxr-- 1 root www-data 5402 Jun 5 20:27 Conversation.php
-rwxrwxr-- 1 root www-data 37347 Jun 5 20:27 DB.php
drwxrwxr-- 2 root www-data 4096 Jun 5 20:27 Entities
drwxrwxr-- 2 root www-data 4096 Jun 5 20:27 Exception
-rwxrwxr-- 1 root www-data 20800 Jun 5 20:27 Request.php
-rwxrwxr-- 1 root www-data 5147 Jun 7 21:50 TelegramLog.php
-rwxrwxr-- 1 root www-data 18623 Jun 5 20:27 Telegram.php
drwxrwxr-- 2 root www-data 4096 Jun 8 21:10 Upload
In my update.log I can see that a new entry is getting generated when sending a file from mobile phone. Per example audio looks like this:
{"update_id":86454387, "message":{"message_id":601,"from":{"id":123456789,"first_name":"myFirstname","last_name":"myLastName"},"chat":{"id":123456789,"first_name":"myFirstname","last_name":"myLastName","type":"private"},"date":1465411058,"voice":{"duration":1,"mime_type":"audio\/ogg","file_id":"AwADBAADBQAD3QozDt94YZV9NlHoAg","file_size":2750}}}
When I try to debug with the setCustomInput function and call the hook.php via browser I don’t get an error.
No related log entry in debug.log or error.log is visible.
Has someone an idea what could cause this issue? Thanks for help!
PHP Version: PHP 5.6.20-0+deb8u1 (cli) (built: Apr 27 2016 11:26:05) Copyright © 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright © 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright © 1999-2016, by Zend Technologies
php-telegram-bot version: 0.33
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (9 by maintainers)
Not by default. I noticed on my bot there is a lot of people who just try to send files to the bot, most likely viruses and stuff.
The uploaded files aren’t saved anywhere automatically at the moment…
What you could do in the meantime, is create a custom command, say
/upload, and then save the uploaded file then.I’ll put together the command for you to use, stay tuned!
If you feel like exploring a bit in the meantime, take a look at the
SurveyCommand.phpfile and look here how to save an uploaded file: https://github.com/akalongman/php-telegram-bot/issues/123#issuecomment-224523310