Skip to main content

Upload files

In order to allow user to upload their own file, you have to define a property with specific type and use simple validation for it:

In structure folder find your concept's JSON file and add the following property type to the list of properties:

"properties" : {
"<property-name>" : "Blob"
}

In validation folder find your concept's JSON file and add the following validation to the list of validations:

"validations" : {
"<property-name>" : {
"content-type" : "<media-type>/*"
}
}

What we did was created a property of type Blob and added a validation that creates a valid input element for media in our interface. Thanks to that user will be able to upload a file that will be treated as a Base64 string.

You can find more on media types here.

Remember to replace <property-name> with the name of your property and <media-type> with the type of media you want to accept.

Also, make sure that when you process this input in your Python code, you decode it from a Base64 string first. You can use the built-in base64 library to decode it and perform your operations on it.

OpenfabricAI Footer