You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
User guide
Object operations
Copy page
Download PDF
Object operations
You can use a command-line tool to perform various operations on an HNS bucket, such as uploading, downloading, and deleting resources.​
Prerequisites​
Relevant commands and examples​
Uploading an object​
Use the following command to upload the file1 file from your local device to the bucket1 bucket.​
​
hdfs dfs -put file1 tos://bucket1/file1​
Or​
hdfs dfs -put file1 tos://bucket1/​
​
Creating a directory​
Use the following command to create a new directory, dir1, in the root directory of the bucket1 bucket.​
​
hdfs dfs -mkdir tos://bucket1/dir1​
​
Viewing object or directory details​
  • Use the following command to list the objects and directories under the dir1 directory.​
​
hdfs dfs -ls tos://bucket1/dir1​
​
  • Use the following command to view information about the file1 object.​
​
hdfs dfs -ls tos://bucket1/file1​
​
  • Use the following command to check the size of the dir1 directory.​
​
hdfs dfs -du tos://bucket1/dir1​
​
Copying an object​
Use the following command to copy the file1 object from the bucket1 bucket to a new object named file3.​
​
hdfs dfs -cp tos://bucket1/file1 tos://bucket1/file3​
​
Downloading an object​
  • Use the following command to download the file1 object from the bucket1 bucket to your local device and rename it file_download.​
​
hdfs dfs -get tos://bucket1/file1 ./file_download​
​
  • Use the following command to read the contents of a text file directly from the command line and display them on the screen.​
​
hdfs dfs -cat tos://bucket1/examplefile.txt​
​
Renaming an object or directory​
  • Use the following command to rename the object file1 to file4.​
​
hdfs dfs -mv tos://bucket1/file1 tos://bucket1/file4 #Rename the object file1 to file4.​
​
  • Use the following command to rename the directory dir1 to dir2.​
​
hdfs dfs -mv tos://bucket1/dir1 tos://bucket1/dir2 #Rename the directory dir1 to dir2.​
​
Deleting an object or directory​
  • Use the following command to delete the file3 object.​
​
hdfs dfs -rm tos://bucket1/file3 #Delete the file3 object.​
​
  • Use the following command to delete the dir2 directory, along with all its objects and subdirectories, recursively.​
  • The -r option indicates that the deletion is recursive.​
​
hdfs dfs -rm -r tos://bucket1/dir2 #Delete the dir2 directory, along with all its objects and subdirectories, recursively. The -r option indicates that the deletion is recursive.​
​
​
Last updated: 2026.03.04 14:36:28