private String getRemoteFileName ( UploadFile file ) { // if the remote path ends with / // it means that the remote path specifies only the directory structure, so // get the remote file name from the local file if ( file . getProperty ( PARAM_REMOTE_PATH ) . endsWith ( "/" ) ) { return file . getName ( service ) ; } // if the remote path contains /, but it's not the last character // it means that I have something like: /path/to/myfilename // so the remote file name is the last path element (myfilename in this example) if ( file . getProperty ( PARAM_REMOTE_PATH ) . contains ( "/" ) ) { String [ ] tmp = file . getProperty ( PARAM_REMOTE_PATH ) . split ( "/" ) ; return tmp [ tmp . length - 1 ] ; } // if the remote path does not contain /, it means that it specifies only // the remote file name return file . getProperty ( PARAM_REMOTE_PATH ) ; }
Checks if the remote file path contains also the remote file name . If it s not specified the name of the local file will be used .