Image upload component Error

Hi ,I am trying to insert image details to the database using image upload component in perspective.Not able to pass image bytes to the method which call named query.Getting error as large file.So how i can achive this.I need to pass it as param.
Thanks in advance

You are sending this image to a database? Can we see the specific error to help determine its origin?

And share your non-working code.

2 Likes

This is the method which insert photo details
def insertphotodetails(fileStream,name):
queryPath="gallery/insertdetails"
queryParams={"fileStream":fileStream,"name":name}
return system.db.runNamedQuery(queryPath,queryParams)

Below is the code which calls above method.
fileStream = event.file.getBytes()
name = event.file.name
insertPhoto = API.v1.Gallery.insertphotodetails.insertphotodetails(fileStream,name)

You're image has cut off important information. Please copy and paste the error stack as preformatted text.

Looks like there is an issue coercing the byte list into another type of value. What is the type of the column that you are attempting to insert the bytes into?

The error is before that, when the parameter is coerced to the value parameter type before sending on to JDBC.

@deepti_k , show your named query definition (with parameter details).

Insert Into  gallery ( filestream , name )values(:filestream,:name) 
filestream :ByteArray
name:string

You didn't show the parameter information, particularly the types of the parameters.

in query?

Yes, how have you configured the parameters in the Named Query.

I see that you have the named query set to use a parameterized database, but you are not providing a database parameter in you script.

Either, set the database connection as appropriate in the Named query, or if it is truly dynamic provide the database parameter.

def insertphotodetails(fileStream,name):
    queryPath="gallery/insertdetails"
    queryParams={"database":"yourDatabaseConnectionName","fileStream":fileStream,"name":name}
    return system.db.runNamedQuery(queryPath,queryParams)

This is not the script that you showed in your earlier post.

thanks it's working now.