Announcement

Collapse
No announcement yet.

Help on file uploads

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help on file uploads

    How do I read the multipart/form-data? I'm trying to read the contents of file upload by using the following:

    Code:
    <form method=post enctype=multipart/form-data>
    <input type=file name=myfile size=30>
    The API suggests data gets put into a struct called "list" with the following function:

    Code:
    list = HttpDecodeMultipartFormData_create(httpClient);
    ...however nothing in your API tells us how to read the data in the list. I tried reading the input box value (ie myfile) and it just returns the filename. In the API there is only one function that reads the list structure called: listLength(list) which returns the size of the list. After digging through the structures, the API doesn't reference the data part of the linked lists, just pointers to the next and prev. How's that?

  • #2
    There is a great question and should have been demonstrated in our cgi.c sample. I will try to update the sample sometime today or tomorrow and post it to the forum.

    Comment


    • #3
      We have discussed the API as it stands today regarding support for reading multipart form data, particularly as it applies to the upload of files from a PC to an Evolution device. On first inspection we originally thought we could just expose an additional structure, but we realized that even this would limit you to file uploads of 40K.

      Therefore, our recommendation is that you retrieve the file from an external host via the TFTPGet function or simply send it to the Evolution device via FTP. This does not give you the same level of control, but is functionally equivalent.

      If you think that you would still like access to multipart form data for file uploads, please give me the details of your use case. This will help us immensely in prioritizing the features for an upcoming release of the SDK.

      Comment


      • #4
        After much time and debugging efforts, I have successfully uploaded and read a file by doing the following:

        1) Making a structure called "http_multipart_data" which was implemented in the first SDK release, but for some reason taken out in the latest SDK realease.

        2) In the CGI code, under the callback, after a POST is detected, I made a node structure called "myData".

        3) Because the "list" structure was already made from the "HttpDecodeMultipartFormData_create" function, I made the list pointer point to the node.

        4) Cast the node pointer to a "http_multipart_data" structure and read data in using something like: fileData = myData->Data

        A little crazy, but it works. I'll try and copy over the code directly some time in the future, especially if its needed by anyone else.

        Comment


        • #5
          I would still like to get your feedback on how you would use a multipart form API. Would it be strictly for file uploads?

          We would like to implement this feature in a manner not limited to 40K file uploads, as is currently the case, and with your feedback we will have a better understanding of your functional requirements and where to prioritize it on our schedule.

          Comment


          • #6
            In evolution_http.h, I added the following:

            Note: This seems to have been taken out of latest release V1.2.0.0R1 and V1.2.0.1R1 when compared to V1.1.0.0R1. Can anyone explain?

            Code:
            struct http_multipart_data {
               struct node node;
               char * contentDisposition;
               char * contentType;
               char * data;
               uint32_t dataLen;
            }
            
            typedef struct http_multipart_data httpMultipartData;
            In my CGI program (just like cgi.c), I added the following lines after the condition for post or multiPartPost:

            Code:
            if(post || multiPartPost) {
            
            struct node *pListFirst = listFirst(list, KEEP_IN_LIST);
            struct http_multipart_data *postedData = (struct http_multipart_data *)pListFirst;
            unsigned char *fileData = (unsigned char *)postedData->data;
            
            }
            From that point, "fileData" had my uploaded file's content.

            Comment


            • #7
              You are correct about the struct http_multipart_data being removed in the latest release of the SDK.

              It is our intent to support multipart form data, but in a manner far different from the API that was defined in the previous SDK release. That implementation preallocated memory to receive the mulitpart form data, and would not support uploads beyond 40K.

              I know its painful when this happens, but we didn't want to retain an API that we would later have to support, even as a new, more capable, multipart form API became available.

              A multipart form data API is not yet on the schedule for implementation, but I will post back with an update when this happens.

              Comment


              • #8
                Did this file upload matter get resolved? I need to upload files > 40 KB and will try the workaround outlined by cmk1523.

                I am currently on version v1.2.0.1R1 of the SDK.

                Thanks
                Chris

                Comment


                • #9
                  There are currently no plans to add a multipart form API to the SDK.

                  Essentially, the situation remains the same.

                  Comment


                  • #10
                    I ended up writing a simple Java applet and Lantronix TCP service to handle the uploads. This was probably better as our uploads probably would not have fit in available memory any way.

                    Chris

                    Comment


                    • #11
                      Thanks for the update Chris.

                      Comment

                      Working...
                      X