All Products
Search
Document Center

Object Storage Service:How to upload and download directories in OSS

Last Updated:Jun 23, 2026

Unlike the hierarchical structure of a traditional file system, OSS uses a flat structure to store data. All data is stored as objects within a bucket. To simplify data management, the OSS console treats any object that has a name ending with a forward slash (/) as a directory. This provides a user experience similar to a file system. This topic describes several ways to upload and download directories.

OSS console

  • Upload a directory: To upload a directory, drag and drop it into the upload area. The directory structure is preserved. For more information, see Upload objects.

  • Download a directory: The OSS console does not support downloading a directory directly. Instead, you can create a local directory and then download objects from the bucket into it in batches. For more information, see Download objects.

OSS SDK

  • Upload a directory: An OSS SDK does not support uploading a directory directly. However, you can upload multiple objects into the same logical directory by setting the same prefix for their object names, followed by a forward slash (/). For example, to upload the files 'example1.txt', 'example2.txt', and 'example3.txt' to a directory named 'dir', you can use the OSS SDK for Java to set the objectName for each object to dir/example1.txt, dir/example2.txt, and dir/example3.txt.

  • Download a directory: An OSS SDK does not support downloading a directory directly. You can only download individual objects within a directory by specifying their full object names. For example, to download all objects from a directory named 'folder' in a bucket to a local directory named 'local':

    • If you know the object names in the 'folder' directory

      For example, if the 'folder' directory contains 'example1.jpg' and 'example2.jpg', you can use the OSS SDK for Java to download them. Set the objectName values to folder/example1.jpg and folder/example2.jpg, and the corresponding local download paths (pathName) to local/folder/example1.jpg and local/folder/example2.jpg.

    • If you do not know the object names in the 'folder' directory

      1. List all objects in the directory by calling the GetBucket (ListObjects) API operation.

      2. Iterate through the list of objects and download each one by setting its objectName and pathName as described previously.

For sample code on uploading and downloading objects with OSS SDKs for various programming languages, see Introduction to OSS SDKs.

ossbrowser GUI

  • Upload a directory: In a bucket or directory, click Folder and select the directory to upload. You can also drag and drop the directory directly into ossbrowser. For more information, see Upload a directory.

  • Download a directory: In the row for the directory to download, click Download. For more information, see Download a directory.

ossutil CLI

  • Upload a directory: Include the -r option in the upload command. For more information, see cp (Upload objects).

  • Download a directory: Include the -r option in the download command. For more information, see cp (Download objects).