All Products
Search
Document Center

Object Storage Service:Use Jindo CLI commands to access OSS-HDFS

Last Updated:Dec 21, 2023

This topic describes how to use Jindo CLI commands to access 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, create a cluster of EMR 3.44.0 or later, or EMR 5.10.0 or later.
  • 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, deploy JindoSDK 4.6.x or later.

Commands and examples

The following section shows how to use Jindo CLI commands to access OSS-HDFS.

  • Upload an object
    Run the following command to upload a file named examplefile.txt in the local root directory to a bucket named examplebucket:
    jindo fs -put examplefile.txt oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/
  • Create a directory
    Run the following command to create a directory named dir/ in a bucket named examplebucket:
    jindo fs -mkdir oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/dir/
  • Query objects or directories
    Run the following command to query the objects or directories in a bucket named examplebucket:
    jindo fs -ls oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/
  • Query the sizes of objects or directories
    Run the following command to query the sizes of all objects or directories in a bucket named examplebucket:
    jindo fs -du oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/
  • Query the content of an object
    Run the following command to query the content of an object named localfile.txt in a bucket named examplebucket:
    jindo fs -cat oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/localfile.txt
    Important 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 an object
    Run the following command to download an object named exampleobject.txt from a bucket named examplebucket 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 directories or objects
    Run the following command to delete a directory named destfolder/ and all objects in the directory from a bucket named examplebucket:
    jindo fs -rm oss://examplebucket.cn-shanghai.oss-dls.aliyuncs.com/destfolder/

For more information, see Jindo CLI user guide.