Shipment.bin file via the Post method

Good afternoon, everyone.
I have a task:
1)My app needs to download a file from a global server(so far, google drive)
2) send this file to the local server via the post method.

through the browser, I can go to my local server, select a file and upload it, but I need to automate this process. So this is what the app should do.

The first point was successful, the file is downloaded and I know the path to it.
but with the second point of the problem:
I tried a large number of different ways to send the file: this is the standard web. post and different extensions, and even tried to run the JS code from the application that was supposed to solve the same problem( the code was generated by the POSTMAN program) and each time I fail.
I saw several similar topics on the form, but my task will be solved by the fact that I can't change the script on the server, I need to send exactly the form that the server needs.
With great respect to the community, I ask for any help. on demand, I will add any materials

My experiment was based on this example:

the form that you need to imitate:

uploading a file from the server:
sending a POST reques:

Hello Евгений

Uploading a file to Google drive is different to uploading to a 'regular' web server, you would normally use Google's method/tools for that.

See this Guide on my fellow Power User Tim's website:

Thank you for your answer, but my problem is not in Google drive at all, I need to transfer the file by the post method to the local server implemented on esp8266

So why on earth did you mention Google drive, but did not mention an esp8266?

Please excuse me if I did not express myself correctly, unfortunately I can only communicate with you with the help of an interpreter. In the text of my question, I said that there are two tasks: the first is to download a file from the global server, the second is to upload this file to a local server (the role of which is performed by esp8266). I managed the first task, but there were problems with the second one.

Hi Евгений, I think your first issue could be the location of the downloaded file. A lot depends on:

  1. What is your Android version
  2. Is this just for you or will you be distributing it as a product to others?

I think you can write your posts in your native language, they translate here via a right-mouse click (Google Translate). Worth a try?

You do mean the Script for the esp8266? I ask because you can program the chip with your own script and you can use the Arduino SDK to accomplish it.

What is important is that the App 'knows' the send format of the data. If you have an existing Script, we need to see it.

Я использую esp8266-7e(f). Прошивка на ней написана мной через Arduino ide.
Для того, что бы иметь возможность OTA обновлений, я добавил в прошивку библиотеку<ESP8266HTTPUpdateServer.h>, пример использования которой есть здесь:прошивка-по-воздуху-контроллера-esp8266-v2-0/
Для реализации OTA в прошивке я вхожу в бесконечный цикл при уникальном событии( например команда build полученная по udp).
Когда esp находится в этом бесконечном цикле, на неё можно зайти через браузер (например там будет форма выбора файла и кнопка загрузить.
Вся работа с html и post скрыта в библиотеке и даже найдя её исходные файлы, я не смог понять как она работает.
По этому задача и сводится к тому, что бы отправить на esp форму post запроса, которая содержит .bin файл и всё.
Касательно версии Android, у меня 10 версия, но должно работать на любой современной версии

That's not to do with the comms, it's to do with Google Security measures. Technically, your Android 10 App may store files in only two directories (folders):

  1. App Specific Directory (aka ASD)
  2. App Private Directory (aka Assets)

This may mean that although you know the path to file 'Shipment.Bin', Android is not allowing access to it. ​

Please do not use acronyms in your posts.

Given that you have written the script, we should know exactly what is required. You can't just send something and hope for the best, as you have already discovered. If "that's it" you wouldn't be here now seeking technical support :thinking:

Shipment.bin - is it actually binary file? As you can see from my post that you have referred to, only certain types of file qualify for the process.

You have adapted my code but the result was the Error message 1104. As discussed in my previous post, that might be down to file type and/or file path.

If you try the attached Project, build an APK for the test, do you get the same error message? Use the 'Pick' button to select a .jpg or .png file from your phone's gallery, then the 'Post' button to send.

PostMedia.aia (5.2 KB)

Shipment.bin это действительно двоичный файл который генерирует Arduino ide (инструменты-экспорт бинарного файла) в котором содержится прошивка для esp8266.
после загрузки файла, библиотека <ESP8266HTTPUpdateServer.h> самостоятельно обновляет прошивку на микроконтроллере и перезагружает его.
Я проверил ваш проект, собрал и запустил на телефоне, вот результат:(изменил только ip адрес на актуальный)

OK, I get the same error here.

We know the Test has a legitimate file path and file type, which should mean that the issue is either with the method of posting, the syntax, the URL or the device itself (it's script).

If I run the Test, sending an image to my Website, no error is reported.

So I think there isn't an error on the send side, but on the receive side. I assume the manufacturer instructs you to add /firmware to the end of the URL?

Another hurdle is the file Content-Type. It should exist in the Web API list of types, but bin (binary) is not listed.

Finally, the jury is out as to which method should used - 'Put' should be put to the Test too (pun intended).

PutMedia.aia (4.9 KB)

Да, так было прописано изначально. я могу изменить эту строчку в прошивке esp8266, но не вижу необходимости.
Так же в прошивке задан порт http сервера - 80:

Использование этого метода приводит к той же ошибке

Записал для вас весь процесс.

Возможно перед отправкой "POST" запроса необходимо сначала отправить "GET"? то есть обратиться к серверу

I don't know - how can a binary file be sent if the Web Api does not accept them?

That would depend on your Script.

Hi again

I have spent some time perusing the internet to see if anyone offers a solution in any programming language. There one or two, but none of them are using Web Api, they are using bespoke APIs that App Inventor does not have access to.

Taifun has a WiFi Extension that uses SSID, Service Set IDentifier, the name of your network. That might be worth looking into.

I'm going to ask my Power User colleague Juan if he knows a way to flash update an ESP8266 via an App + WiFi.

По этому задача и сводится к тому, что бы отправить на esp форму post запроса, которая содержит .bin файл и всё.

Therefore, the task comes down to sending a post request form to esp, which contains a .bin file and that's it.

My experience has been to upload files to a SdCard on ESP32 through a web page following this tutorial:

I don't know if this idea will work for you (I haven't tried it): upload the file to the SPIFFS of ESP8266, from the App using the CustumWebView extension, following this tutorial:

Большое спасибо за ваше активное участие.
Касательно WiFi от Taifun можно по подробнее? Пока не увидел, что в этом расширении может помочь в решении нашей проблемы