# Using FreeRTOS+coreHTTP as a example to make chunk upload to aws s3

**URL:** <https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649>\
**Category:** AWS\
**Tags:** debug\
**Created:** [October 17, 2024, 3:01pm UTC](https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649 "2024-10-17T15:01:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.dabrowski](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@p.dabrowski](https://forums.freertos.org/u/p.dabrowski)\
**Post date:** [October 17, 2024, 3:01pm UTC](https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649/1 "2024-10-17T15:01:43Z")

</div>

Hi,  
I have a problem where I am firstly connect to IOT to get the temporary credentials then connect to aws and send HTTP request. I converted the code from the link above: [FreeRTOS/FreeRTOS-Plus/Demo/coreHTTP\_Windows\_Simulator/HTTP\_S3\_Download/DemoTasks/S3DownloadHTTPExample.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download/DemoTasks/S3DownloadHTTPExample.c)  
To enable sending chunks and I send them as described here:  
[Signature Calculations for the Authorization Header: Transferring Payload in Multiple Chunks (Chunked Upload) (AWS Signature Version 4) - Amazon Simple Storage Service](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html)  
At the moment, I can send maximum of 96,4KB in a single file that has 11 chunks each one of 8976B and the last empty as described in the previous link, everything works. But when I have a larger file than 9640 KB on my sd card it always stops uploading at 101 file. Upload works for up to 100 files in the s3 directory. What could be the problem since this always happens, even when I upload 3 chunks first 8KB second 1 KB and the third 0KB total uploaded file has 9KB and It always stops uploading on file 101 and i can’t received any response from the server. Can it be problem with the settings of aws?  
Second question is that the aws server is not responding and when i am uploading much more chunks for example 25 even any value greater than 11 i get stuck because tcp buffer is full and the server not doing the ACK response to make tcp buffer free as the protocol should work. And it is all works like this:  
Firstly I send the HTTP request without body:  
httpStatus = HTTPClient\_Send(ptransportInterface,  
&requestHeaders,  
NULL,  
0,  
&(response),  
(HTTP\_SEND\_DISABLE\_CONTENT\_LENGTH\_FLAG | HTTP\_SEND\_DO\_NOT\_RECEIVE\_FLAG));  
And then in the loop i send the chunks with the signature calculated  
uint32\_t sendFlags = (HTTP\_SEND\_DISABLE\_CONTENT\_LENGTH\_FLAG |  
HTTP\_SEND\_DO\_NOT\_SEND\_HEADERS\_FLAG |  
HTTP\_SEND\_DO\_NOT\_RECEIVE\_FLAG);  
httpStatus = HTTPClient\_Send(ptransportInterface,  
&requestHeaders,  
&(pBufferToSend[0]),  
chunkLength,  
&(response),  
sendFlags);  
And the last chunk required by Transfer-Encoding.  
httpStatus = HTTPClient\_Send(ptransportInterface,  
&requestHeaders,  
“0\r\n\r\n”,  
sizeof(“0\r\n\r\n”) - 1,  
&(response),  
(HTTP\_SEND\_DISABLE\_CONTENT\_LENGTH\_FLAG | HTTP\_SEND\_DO\_NOT\_SEND\_HEADERS\_FLAG));

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 18, 2024, 6:21am UTC](https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649/2 "2024-10-18T06:21:01Z")

</div>

> [@p.dabrowski](#):
>
> i can’t received any response from the server.

Can you break the program in the debugger and see what it is doing? Also, please capture network trace and share.

> [@p.dabrowski](#):
>
> because tcp buffer is full and the server not doing the ACK

How did you determine that?

---

<div class="post-metadata">

**Author:** ![p.dabrowski](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@p.dabrowski](https://forums.freertos.org/u/p.dabrowski)\
**Post date:** [October 18, 2024, 1:12pm UTC](https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649/3 "2024-10-18T13:12:53Z")

</div>

What do you mean “break the program in the debugger and see what it is doing”?  
When i send 101 file i get stuck in program in line with cyw43\_arch\_poll(); here:

```auto
int32_t recvUsingLwIP(NetworkContext_t *pNetContext, void *buf, size_t buflen)
{
    int32_t ret = ERR_VAL;
    if(buf == NULL)
    {
        printf("Error: recvUsingLwIP - buf pointer is NULL\n");
        return ret;
    }
    if(pNetContext == NULL)
    {
        printf("Error: recvUsingLwIP - Network Context pointer is NULL\n");
        return ret; 
    }
    if(buflen < 1)
    {
        printf("Error: recvUsingLwIP - buf less then 1\n");
        return ret;
    }

    while(1)
    {
        cyw43_arch_poll();
        if(pNetContext->readFlag == 1)
        {
            pNetContext->readFlag = 0;
            memcpy(buf, lwipRecToCorehttpRec, pNetContext->bytesToRecv);
            memset(lwipRecToCorehttpRec, 0, sizeof(lwipRecToCorehttpRec));
            return pNetContext->bytesToRecv;
        }
    }
    
}

```

I know my tcp buffer is full because I used this function: altcp\_sndbuf(pNetContext-\>pcb);

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 21, 2024, 5:30am UTC](https://forums.freertos.org/t/using-freertos-corehttp-as-a-example-to-make-chunk-upload-to-aws-s3/21649/4 "2024-10-21T05:30:54Z")

</div>

> [@p.dabrowski](#):
>
> What do you mean “break the program in the debugger and see what it is doing”?  
> When i send 101 file i get stuck in program in line with cyw43\_arch\_poll(); here:

That is what I wanted to know - i.e. the function call where the code is stuck. Where does this function coms from? Is it possible for figure out why this function is stuck?
