How to upload a file in gateway file system

hi ,
i want to upload a file in gateway file system to access the file in perspective.

i tried using file upload component . i just clicked browse in the component and uploaded my excel file .
where it will be stored? how can i retrive?

you have to store it somewhere yourself in the function onFileReceived
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+File+Upload
https://docs.inductiveautomation.com/display/DOC81/system.file.writeFile
https://docs.inductiveautomation.com/display/DOC81/system.file.readFileAsBytes

i tried to read my file path as bytes using system.file.readFileAsBytes but i am getting the below error.

TypeError: readFileAsBytes(): 1st arg can’t be coerced to String

My code:
inputpath=system.db.runPrepQuery(“SELECT file_path FROM logbook_master_excel WHERE s_no=‘1’”)
inputFile=system.file.readFileAsBytes(inputpath)
print inputFile

even tried as:
inputByte=system.db.runPrepQuery(“SELECT file_byte FROM logbook_master_excel WHERE s_no=‘1’”)
inputFile=system.file.readFileAsBytes(inputByte)
print inputFile

this is not the correct syntax for a prepquery
https://docs.inductiveautomation.com/display/DOC81/system.db.runPrepQuery

and a prepquery does not return a string but a pydataset

Also if you are storing the filepath in the database, why not store the whole file there? xd

i have uploaded whole file as byte in database using file upload component in perspective. how can i retrive?
when i tried using readFileAsBytes() it is throwing the same error.
TypeError: readFileAsBytes(): 1st arg can’t be coerced to String

system.file.readFileAsBytes reads a file out of a folder on the gateway. where the argument has to be the filepath (string)

please provide the code inside the onFileReceived event

format it by first pressing </>

also what kinda files are you uploading and what do you want to do with it? You said an excel file? You want them to download the file again?

i am having a excel file uploaded in database . i want to read that file and update the data in required co-ordinates in excel and convert them into output file in local system.

When you run a query on your database table that contains the file in a blob column, the result dataset will have a byte array for that column’s dataset. There’s no file read needed at all. Just send the column value as the bytes in system.perspective.download.

Please use the </> code formatting button when posting code. It preserves indentation and you get free syntax highlighting. For inline portions of code you can `simply enclose in backticks`.