No direct way but you can following approach.
- Upload file with your existing code.
- Get File/Folder to get file uploaded in step 1 to check metadata
- If metadata as per requirement, do nothing else, delete the file.
Hope this workaround will work.
Thanks,
Ashok