This topic describes how to use Jindo CLI commands to access Object Storage Service (OSS) and OSS-HDFS.
Environment preparation
- In the E-MapReduce (EMR) environment, JindoSDK is installed by default and can be directly used. Note To access OSS-HDFS, you must create a cluster of EMR V-3.44.0 or a later minor version, or EMR V5.10.0 or a later minor version.
- In a non-EMR environment, install JindoSDK first. For more information, see Deploy JindoSDK in an environment other than EMR. Note To access OSS-HDFS, you must install JindoSDK V4.6.X or later.
Commands and examples
You can use Jindo CLI commands to access OSS and OSS-HDFS in the same way. The difference lies in the endpoints in paths.
- Upload a fileRun the following command to upload a file named examplefile.txt in the local root directory to a bucket named examplebucket in OSS-HDFS:
jindo fs -put examplefile.txt oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/ - Create a directoryRun the following command to create a directory named dir/ in a bucket named examplebucket in OSS-HDFS:
jindo fs -mkdir oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/dir/ - Query files or directoriesRun the following command to query the files and directories in a bucket named examplebucket in OSS-HDFS:
jindo fs -ls oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/ - Query the sizes of files or directoriesRun the following command to query the sizes of all files and directories in a bucket named examplebucket in OSS-HDFS:
jindo fs -du oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/ - Query the content of a fileRun the following command to query the content of a file named localfile.txt in a bucket named examplebucket in OSS-HDFS:
jindo fs -cat oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/localfile.txtImportant The content of the queried file is displayed in plain text. If the content is encoded, use HDFS API for Java to read and decode the content. - Download a fileRun the following command to download a file named exampleobject.txt from a bucket named examplebucket in OSS-HDFS to a directory named /tmp in the root directory of your computer:
jindo fs -get oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/exampleobject.txt /tmp/ - Delete files or directoriesRun the following command to delete a directory named destfolder/ and all files in the directory from a bucket named examplebucket in OSS-HDFS:
jindo fs -rm oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/destfolder/
For more information about commands and their descriptions, see Use Jindo CLI.