18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Having problems using _setFile function
Hello,
I'm new to Sahi. In the last couple of weeks of playing around I have been able to automate everything without any issues with the exception of the file upload function _setFile().
I enable the debug traffic log option in the Sahi properties file and ran my file upload both manually and using _setFile() with the following results...
Manually (works fine):
request body for the upload URL (http s://mydomain.com/aqs/myAccount/saveLogo)
28400655821476
Content-Disposition: form-data; name="file"; filename="test_260x70.png"
Content-Type: image/png
{file content is shown here}
28400655821476--
Now with _setFile (not working)
_setFile request.body...(the file "test.260x70.png" is located on the proxy server drive)
n=file&v=c%3A%5Ctest_260x70.png&action=https%3A%2F%2Fmydomain. com%2Faqs%2Fis%2Fmain%2FmyAccount%2FsaveLogo&t=1272638338686
Request body for the upload URL (http s://mydomain.com/aqs/myAccount/saveLogo)
17035989428703
Content-Disposition: form-data; name="file"; filename=""
Content-Type: application/octet-stream
17035989428703--
The following message is displayed on the proxy...
url: http s://mydomain.com/aqs/is/main/myAccount/saveLogo
command: FileUpload_appendFiles
Uploading: fileName = c:\test_260x70.png
Any help with this would be appreciated...not sure what to do next.
Thanks,
Eric.
I'm new to Sahi. In the last couple of weeks of playing around I have been able to automate everything without any issues with the exception of the file upload function _setFile().
I enable the debug traffic log option in the Sahi properties file and ran my file upload both manually and using _setFile() with the following results...
Manually (works fine):
request body for the upload URL (http s://mydomain.com/aqs/myAccount/saveLogo)
28400655821476
Content-Disposition: form-data; name="file"; filename="test_260x70.png"
Content-Type: image/png
{file content is shown here}
28400655821476--
Now with _setFile (not working)
_setFile request.body...(the file "test.260x70.png" is located on the proxy server drive)
n=file&v=c%3A%5Ctest_260x70.png&action=https%3A%2F%2Fmydomain. com%2Faqs%2Fis%2Fmain%2FmyAccount%2FsaveLogo&t=1272638338686
Request body for the upload URL (http s://mydomain.com/aqs/myAccount/saveLogo)
17035989428703
Content-Disposition: form-data; name="file"; filename=""
Content-Type: application/octet-stream
17035989428703--
The following message is displayed on the proxy...
url: http s://mydomain.com/aqs/is/main/myAccount/saveLogo
command: FileUpload_appendFiles
Uploading: fileName = c:\test_260x70.png
Any help with this would be appreciated...not sure what to do next.
Thanks,
Eric.
This discussion has been closed.
Comments
The debug logs show the data before Sahi has appended the file to the request. I think your application is not accepting the image because the mime-type is incorrect.
Open mime-types.mapping file in sahi/config directory and add
.png image/png
at the end, so that the file looks like
...
.jpg image/jpeg
.jpeg image/jpeg
.png image/png
Restart Sahi and check again.
Regards,
Narayan