AWS uploaded file name?

Hello,

I’ve build an application with a ConnectME and Net+Os 7.3 which need configuration files. I’ve build a form to upload file and it work, but I can’t find a way to get the uploaded file name. (So for now I’ve hardcoded a “myconf.cfg” name, and I need to upload file with the this name… not cool).

Is there a way in the code of AWS pages to get this name ?
(I’ve started with the sample application with file upload capabilitie: it has a function upload_submit() in filelist_v.c which is called after the upload has finished. The FilelistPgCache contain a NAFS_DIR_ENTRY_INFO, but it’s always empty…)

Or an jscript way to always upload the file with an hardcoded name (ugly but ok for me)

Thanks in advance!

Hello

There is no "easy" way to perform the operation that you discuss in your posting. The only ways I can think of to perform them would be:

a) as you discuss, always upload a configuration file of a known name

b) The file file.c that is compiled into all AWS (Advanced Web Server) applications that include the file system, is the interface file between the AWS and the file system. You’d need to rummage around file.c to find a place where you can grab the file name.

Can you share the code you used to hardcode the “myconf.cfg” for uploading? I am using an AWS application and this will work for what I am trying to do.

Thank you so much in advance,
Ed Sudit

Thanks for the quick reply.

I will look in file.c and see what I can do.

Ok, I was able to do what I wanted in RpHSCreateFile(), I just need to check that I didn’t break the firmware update feature :slight_smile:

Realy ugly hack , ButItWork™

Needed both name and size of file. File size zero helps in detecting case when user hits upload button without selecting a file.

Added these function in file.c:

char * getFileName(int theFileNumber)
{
RPFS_BUFFER_T *pFileReq = Get_FileSystemBuffer theFileNumber);
return pFileReq->file_name;
}
int getFileSize(int theFileNumber)
{
RPFS_BUFFER_T *pFileReq = Get_FileSystemBuffer(theFileNumber);
return pFileReq->file_info.FileSize;
}

/* Used added functions in upload_submit() */
void upload_submit(void *theTaskDataPtr, Signed16Ptr theIndexValuesPtr)
{

char fileName[120];

int theFileNumber = RpGetCurrentConnection(theTaskDataPtr); // conn == fNum by design in file.c
int fileSize = getFileSize(theFileNumber);
strcpy(fileName, getFileName(theFileNumber));


}