Is there a known LOW limit to files uploaded with HTTP POST?
I am able to POST files with ~ 1200 bytes, but not anything less than that.
Thanks.
POSTing where, how, with what, to what
POSTing where:
From AIAPP to a Server directory
how:
Using the Web POST file block
with what: ???
to what:
To a server php program
I have checked the forum posts and there was no relevant entry. So do not understand your canned cut/paste.
Did you understand this part ?
Before being able to provide you support, we need to know as much as possible about what your are trying to achieve, and how your are going about it. We don't know if it is an AI2 issue because there are so many external variables that come into play. From what you have said:
You are using the web component with the POST (file?) block ?
You are posting files (?) but we don't know what type of files ?
You are posting to an online server which is running a "php program", but we don't know how the php program works, how the server is setup or what is being used to store the file once it arrives at the server ? Is it your own server ? LAMP/WAMP/Other ? php/mySQL or just php ?
Have you been through the server configuration to check for settings that might be causing this ?
Can you upload any file through other means, curl etc ?
Help us to help you.....
Also
This suggests a timing problem, where the small size of the file is causing the transmitter to machine gun the files faster than the receiving end can file them.
Does the receiving end announce readiness for the next file, so the transmitting side can use that as a trigger for sending the next file?
Alternative idea:
I vaguely remember a limit of 256 files per directory in some old operating system versions. Does your small file size cause increased directory size, hitting some O/S limit?
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
@ABG: Thank you for your reply and alternatives.
Additional Info:
Files are jpg or png pictures. They are being transmitted one at a time, not in batches of many. Existing code pair (AI and PHP) sends and receives successfully anything that is larger than approx. 1200 bytes. Once I go below that size, nothing even transmits. On a NOTEII (Android Ver 4.4.2) I get no errors, but on a S5 (Android Ver 6.0.1) I get 1104 error after waiting over a few minutes.
Can anyone confirm if they are able to xmit files of 1 - 1K size range ?
AI2 Blocks:
PHP:
<?php
/* FileName: PicXfer.php
* Simple PHP script to save image file.
*/
echo "We're in the XFER Program...";//phpinfo();
$picDir = "Images/";
$fileName = $_REQUEST['pic'];
$startT = microtime(TRUE);
echo "\nReceiving: $fileName \n";
$dataToWrite = file_get_contents('php://input');
$fileStatus = file_put_contents($picDir.$fileName, $dataToWrite);
$dur = microtime(TRUE) - $startT;
echo "\nBytes written: $fileStatus \nDuration: $dur";
?>
I set this up on my server, and tested with a small jpg 997 bytes.
Using companion this uploaded just fine to the server with the expected response from the php:
We're in the XFER Program...
Receiving: tinypic.jpg
Bytes written: 997
Duration: 0.0002620221843262
Must be something on your server ?
These are very small images......
I used companion on my genymotion emulator (Google Pixel 3XL/Android 9), can test on other emulated devices / android versions or on real device HTC10/Android 7
One thing we haven't considered, is that it could be the files?
Put up a couple of files that "won't upload", for testing...
Never uploaded pics like this before.I hope it works OK.
Test Files
Both files uploaded fine here - using picXfer
Thank you very much Tim. I will look into other devices to see what is happening here.
It may be worth checking your php.ini file or phpinfo.php for the following, and then set/change values if necessary:
memory_limit = 256M
upload_max_size = 64M
post_max_size = 64M
upload_max_filesize = 64M
max_execution_time = 300
max_input_time = 1000
On checking my own server I have these, but the uploads worked fine:
memory_limit = 128M
upload_max_size = 64M
post_max_size = 64M
upload_max_filesize = 64M
max_execution_time = 30
max_input_time = 60
Does the file_put_contents call return immediately, or does it return only after the file has been completely stored? (Synchronous or Asynchronous?)
Is there an event that should be set up to receive control when the storage work has completed?
Note in AI2 that file writing is asynchronous, with a File event block to grab control when the file has written.
Does PHP work similarly?
@ABG:
Even though I do not know for a fact, I am leaning towards "it returns only after the file has been completely stored". The reason being that my PHP timing takes up to several seconds for very large files; and I am displaying that millis time upon return.
@TIMAI2:
My server values are the same except max_input_time = 60. Mine is -1, which means it defaults to max-execution-time.
I was able to capture one of the error messages displayed, in case it means anything to you guys:
I am thinking that the POST never actually happens in my environment, for some strange reason !
That leading underscore (_) in one of the directory names is unusual.
Here's a recent Error 1104 thread from search results ...
Created by the ImagePicker block automatically.
I tried uploading one of the non-xfering images as Media and use a manual transfer from the program directory, where the file name is only the lastpart.jgp.
Same thing happens. Small ones don't go, big ones do !