Before saving a node how to get the file path For a content type "TEST" which has a field "upload file", I want the file path before saving the node. 
hook_node_presave can be used to do anything before saving the node.
I want to rename the file before it get saved into database.

but my file is getting saved first into the database.

How to do rename a file before it gets saved into database in a custom module.
Check out hook_file_presave() function.

You might have to additionally rename/move the file after it has been uploaded.

See also this thread and check the File (Field) Paths module as it might have already the functionality you need.