Fledge
An open source edge computing platform for industrial users
FormData Class Reference

This class represents a parsed HTTP form data uploaded to SimpleWeb::Server<SimpleWeb::HTTP. More...

#include <form_data.h>

Classes

class  FieldValue
 

Public Member Functions

 FormData (std::shared_ptr< SimpleWeb::Server< SimpleWeb::HTTP >::Request > request)
 
void getUploadedData (const std::string &field, FieldValue &data)
 Fetch content data uploaded without file, example curl -v -v -v –output - -X POST -F 'attributes={"name": "B1", "type": "model"}' 127.0.0.1:43605/fledge/south/uploadA. More...
 
void getUploadedFile (const std::string &field, FieldValue &data)
 Fetch content data uploaded as file, example curl -v -v -v –output - -X POST -F "bucket=@/some_path/file.bin" 127.0.0.1:43605/fledge/south/uploadA. More...
 
bool saveFile (FieldValue &b, const std::string &fileName)
 Save the uploaded file. More...
 

Detailed Description

This class represents a parsed HTTP form data uploaded to SimpleWeb::Server<SimpleWeb::HTTP.

FormData::FieldValue holds the field value as buffer start, size and filename if data comes form a file upload

FormData holds the input buffer, size and boundary multipart data

Public methods fetch value of a given field name and save file to filesystem

Member Function Documentation

◆ getUploadedData()

void FormData::getUploadedData ( const std::string &  field,
FieldValue data 
)

Fetch content data uploaded without file, example curl -v -v -v –output - -X POST -F 'attributes={"name": "B1", "type": "model"}' 127.0.0.1:43605/fledge/south/uploadA.

Parameters
fieldThe field name to fetch
dataThe value reference to fill on success

◆ getUploadedFile()

void FormData::getUploadedFile ( const std::string &  field,
FieldValue data 
)

Fetch content data uploaded as file, example curl -v -v -v –output - -X POST -F "bucket=@/some_path/file.bin" 127.0.0.1:43605/fledge/south/uploadA.

Parameters
fieldThe field name (filename type) to fetch
dataThe value reference to fill on success

◆ saveFile()

bool FormData::saveFile ( FieldValue b,
const std::string &  fileName 
)

Save the uploaded file.

Parameters
vThe Field value data
Returns
Returns true if the file was succesfully saved

The documentation for this class was generated from the following files: