React-native-fs: Can we get file name by passing uri to RNFS?

Created on 2 Feb 2018  路  3Comments  路  Source: itinance/react-native-fs

question

Most helpful comment

let filename = uri.substring(uri.lastIndexOf('/') + 1, uri.length())

All 3 comments

let filename = uri.substring(uri.lastIndexOf('/') + 1, uri.length())

@JohnRyanTsai I'm assuming you're asking this because you want to be able to upload files right? I'm confused why there is not a native method for this and we would need to use something like what @est7 suggested above.

Specifically regarding uploadFiles, I'm surprised that we have to pass the filename, and not just the file path, if the logic to deduce the filename is really that simple.

let filename = uri.substring(uri.lastIndexOf('/') + 1, uri.length())

let filename = uri.substring(uri.lastIndexOf('/') + 1, uri.length)

Was this page helpful?
0 / 5 - 0 ratings