Huawei Drive
Paths are specified as huaweidrive:path
Huawei Drive paths may be as deep as required, e.g. huaweidrive:directory/subdirectory.
Configuration
The initial setup for Huawei Drive involves getting a token from Huawei Drive
which you need to do in your browser. rclone config walks you
through it.
Here is an example of how to make a remote called remote. First run:
rclone config
This will guide you through an interactive setup process:
No remotes found, make a new one?
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
n/r/c/s/q> n
name> remote
Type of storage to configure.
Choose a number from below, or type in your own value
[snip]
XX / Huawei Drive
\ "huaweidrive"
[snip]
Storage> huaweidrive
OAuth Client Id - leave blank to use rclone's default.
client_id>
OAuth Client Secret - leave blank to use rclone's default.
client_secret>
Remote config
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes
n) No
y/n> y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Configuration complete.
Options:
- type: huaweidrive
- client_id:
- client_secret:
- token: {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2024-03-16T13:57:58.955387075Z"}
Keep this "remote" remote?
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
See the remote setup docs for how to set it up on a machine without an internet-connected web browser available.
Note that rclone runs a webserver on your local machine to collect the
token as returned from Huawei if using web browser to automatically
authenticate. This only runs from the moment it opens your browser to the moment you get back
the verification code. This is on http://127.0.0.1:53682/ and it
may require you to unblock it temporarily if you are running a host
firewall, or use manual mode.
You can then use it like this,
List directories in top level of your drive
rclone lsd remote:
List all the files in your drive
rclone ls remote:
To copy a local directory to a drive directory called backup
rclone copy /home/source remote:backup
Getting your own Client ID and Secret
When you use rclone with Huawei Drive in its default configuration you are using rclone's client_id. This is shared between all the rclone users. There is a global rate limit on the number of queries per second that each client_id can do set by Huawei.
It is strongly recommended to use your own client ID as the default rclone ID is heavily used. If you have multiple services running, it is recommended to use a separate client ID for each service to avoid rate limiting issues.
Here is how to create your own Huawei Drive client ID for rclone:
Follow the detailed guides for complete setup instructions:
Rclone uses the web application access method to connect to Huawei Drive. Before starting, you need to implement quick login authorization through Huawei Account Open Service. With user authorization credentials, rclone can call Huawei Cloud Drive Service APIs.
Create Server Application
Before accessing Drive service, developers need to create a server application first. For details, please refer to the WEB Application Access Development Preparation section in the "Huawei Account Service Development Guide".
Enable Drive Application Switch
- Log in to the AppGallery Connect website and click "My Projects".
- Find your project in the project list, select the application that needs to access Drive in the project, and click "API Management".
- In the "API Management" area of the "Project Settings" page, click the switch on the right side of Drive Kit to ensure the switch is in the open state.
Sign Huawei Cloud Drive Privacy Notice and User Agreement
Guide users to visit https://cloud.huawei.com/. First-time users need to sign the agreement before they can use Huawei Cloud Drive Service.
Application Access to Obtain Authentication Credential Access Token
Applications accessing Drive should use authentication credential Access Token. For specific acquisition methods, please refer to the WEB Application Access Development Guide section in the "Huawei Account Service Development Guide".
Key steps summary:
-
Log into the Huawei Developer Console with your Huawei account.
-
Create a new project or select an existing project.
-
Go to "Manage APIs" and enable the "Drive Kit" API.
-
Click on "Credentials" in the left side panel.
-
Click "Create Credentials" and choose "OAuth client ID".
-
Choose "Web application" as the application type.
-
Add
http://localhost:53682/to the "Authorized redirect URIs". -
Click "Create" and note down the Client ID and Client Secret.
-
Provide the noted client ID and client secret to rclone during configuration.
Scopes
Rclone uses the following OAuth2 scopes when accessing Huawei Drive:
https://www.huawei.com/auth/drive- Full access to Huawei Drive files (excluding application data folder)https://www.huawei.com/auth/drive.file- Access to files created by the applicationopenid- OpenID Connect authenticationprofile- Access to basic profile information
The drive.file scope is included in the default set used by rclone.
Alternative scopes available (not used by rclone by default):
https://www.huawei.com/auth/drive.appdata- Access to application data folderhttps://www.huawei.com/auth/drive.readonly- Read-only access to file metadata and contenthttps://www.huawei.com/auth/drive.metadata- Read/write access to file metadata onlyhttps://www.huawei.com/auth/drive.metadata.readonly- Read-only access to file metadata only
The default scopes provide read/write access to all files in your Huawei Drive.
Modification times and hashes
Huawei Drive does not support setting modification times. The API
always uses server-side timestamps, so file modification times from
the source are not preserved during upload. Modification times are
available as read-only metadata (mtime, btime).
Hash algorithm SHA256 is supported for file integrity verification.
Restricted filename characters
Huawei Drive has strict restrictions on file and directory names:
- Cannot contain:
< > | : " * ? / \or emoji characters - Cannot be exactly
. .. - Maximum length: 250 bytes
- Single quotes must be escaped with
\'in API calls
These restrictions are handled by rclone's encoding:
- Backslashes
\are encoded - Invalid UTF-8 sequences are encoded
- Right-side spaces are encoded
Invalid characters will be replaced according to the encoding settings.
Resumable uploads
Huawei Drive supports resumable uploads for files larger than the upload cutoff (default 20MB). Files are uploaded in chunks which allows for recovery from network interruptions.
File size limits
The maximum file size for Huawei Drive is 50 GiB.
Quota information
To view your current quota you can use the rclone about remote:
command which will display your usage and quota information.
Standard options
Here are the Standard options specific to huaweidrive (Huawei Drive).
--huaweidrive-client-id
OAuth Client Id.
Leave blank normally.
Properties:
- Config: client_id
- Env Var: RCLONE_HUAWEIDRIVE_CLIENT_ID
- Type: string
- Required: false
--huaweidrive-client-secret
OAuth Client Secret.
Leave blank normally.
Properties:
- Config: client_secret
- Env Var: RCLONE_HUAWEIDRIVE_CLIENT_SECRET
- Type: string
- Required: false
Advanced options
Here are the Advanced options specific to huaweidrive (Huawei Drive).
--huaweidrive-token
OAuth Access Token as a JSON blob.
Properties:
- Config: token
- Env Var: RCLONE_HUAWEIDRIVE_TOKEN
- Type: string
- Required: false
--huaweidrive-auth-url
Auth server URL.
Leave blank to use the provider defaults.
Properties:
- Config: auth_url
- Env Var: RCLONE_HUAWEIDRIVE_AUTH_URL
- Type: string
- Required: false
--huaweidrive-token-url
Token server url.
Leave blank to use the provider defaults.
Properties:
- Config: token_url
- Env Var: RCLONE_HUAWEIDRIVE_TOKEN_URL
- Type: string
- Required: false
--huaweidrive-client-credentials
Use client credentials OAuth flow.
This will use the OAUTH2 client Credentials Flow as described in RFC 6749.
Note that this option is NOT supported by all backends.
Properties:
- Config: client_credentials
- Env Var: RCLONE_HUAWEIDRIVE_CLIENT_CREDENTIALS
- Type: bool
- Default: false
--huaweidrive-root-folder-id
ID of the root folder.
Normally this is auto-detected, but if it fails or you want to speed up startup, you can set it manually.
Leave blank normally.
Properties:
- Config: root_folder_id
- Env Var: RCLONE_HUAWEIDRIVE_ROOT_FOLDER_ID
- Type: string
- Required: false
--huaweidrive-chunk-size
Upload chunk size.
Must be a power of 2 >= 256k and <= 64MB.
Properties:
- Config: chunk_size
- Env Var: RCLONE_HUAWEIDRIVE_CHUNK_SIZE
- Type: SizeSuffix
- Default: 8Mi
--huaweidrive-list-chunk
Size of listing chunk 1-1000.
Properties:
- Config: list_chunk
- Env Var: RCLONE_HUAWEIDRIVE_LIST_CHUNK
- Type: int
- Default: 1000
--huaweidrive-upload-cutoff
Cutoff for switching to resumable upload.
Any files larger than this will be uploaded using resumable upload. The minimum is 0 and the maximum is 20 MiB (Huawei Drive API limit for single request uploads).
Properties:
- Config: upload_cutoff
- Env Var: RCLONE_HUAWEIDRIVE_UPLOAD_CUTOFF
- Type: SizeSuffix
- Default: 20Mi
--huaweidrive-encoding
The encoding for the backend.
See the encoding section in the overview for more info.
Properties:
- Config: encoding
- Env Var: RCLONE_HUAWEIDRIVE_ENCODING
- Type: Encoding
- Default: Slash,LtGt,DoubleQuote,Colon,Question,Asterisk,Pipe,BackSlash,Del,Ctl,LeftSpace,LeftPeriod,LeftTilde,RightSpace,RightPeriod,InvalidUtf8,Dot
--huaweidrive-description
Description of the remote.
Properties:
- Config: description
- Env Var: RCLONE_HUAWEIDRIVE_DESCRIPTION
- Type: string
- Required: false
Metadata
Huawei Drive supports reading and writing custom metadata.
User metadata can be set using the "properties" field in the API. System metadata includes standard file information such as:
- content-type: MIME type of the object
- description: User-provided description
- favorite: Whether file is marked as favorite
- btime/mtime/utime: Various timestamps
- sha256: File hash
- recycled/has-thumbnail: File status flags
Custom metadata keys can be any string and will be stored in the file's properties.
Here are the possible system metadata items for the huaweidrive backend.
| Name | Help | Type | Example | Read Only |
|---|---|---|---|---|
| btime | Time when the file was created (RFC 3339) | RFC 3339 | Y | |
| content-type | MIME type of the object | string | Y | |
| description | Description of the file | string | N | |
| favorite | Whether the file is marked as favorite (true/false) | string | N | |
| has-thumbnail | Whether the file has a thumbnail (true/false) | string | Y | |
| mtime | Time when the file content was last modified (RFC 3339) | RFC 3339 | Y | |
| recycled | Whether the file is in recycle bin (true/false) | string | Y | |
| sha256 | SHA256 hash of the file | string | Y | |
| utime | Time when the file was last edited by the current user (RFC 3339) | RFC 3339 | Y |
See the metadata docs for more info.
Limitations
Huawei Drive has some rate limiting which may cause rclone to slow down transfers to avoid hitting the limits.
File name restrictions
- File names cannot contain:
< > | : " * ? / \ - File names cannot be exactly
. .. - Maximum file name length is 250 bytes
- Some unicode characters including emojis are not supported
API rate limits
Huawei Drive imposes API rate limits. Rclone automatically handles these by backing off when limits are hit.
OAuth2 token expiry
- Access tokens expire after 1 hour
- Refresh tokens expire after 180 days
- Rclone will automatically refresh tokens as needed
File size limits
- Maximum file size is 50 GiB
- Files larger than this cannot be uploaded
Upload behavior
- Files smaller than
upload_cutoff(default 20MB) are uploaded in a single request using content or multipart method - Larger files are uploaded using resumable uploads with configurable chunk size
- Maximum single chunk size for resumable uploads is 64MB
- Resumable uploads support automatic retry on network errors
- SHA256 hash verification is supported for uploaded files
Server-side operations
- Server-side copy: Files can be copied within Huawei Drive without downloading and re-uploading
- Server-side move: Files and directories can be moved/renamed on the server side
- Directory move: Entire directories can be moved with a single API call
Directory operations
- Huawei Drive supports creating empty directories
- Recursive listing is supported via
--fast-listfor efficient directory traversal - Huawei Drive has a special "applicationData" folder for app-specific data (not accessible via rclone's default configuration)
Error handling
Common errors and their meanings:
401 Unauthorized: Invalid credentials or expired token403 Forbidden: Usually indicates insufficient permissions or API quota exceeded404 Not Found: File or directory does not exist409 Conflict: Directory already exists429 Too Many Requests: API rate limit exceeded, rclone will automatically retry
Performance tuning
For better performance:
- Increase
--transfersfor concurrent operations (default is 4) - Adjust
chunk_sizebased on your network speed and file sizes - Use
--fast-listfor operations on directories with many files to reduce API calls
Making backups
Huawei Drive is suitable for backups with some considerations:
- Use
rclone syncrather thanrclone copyto maintain exact directory structure - Consider using
--backup-dirto preserve deleted files - Verify transfers with
--checksumflag for critical data - Be aware of the 50 GiB file size limit for individual files
Supported features
Huawei Drive supports the following rclone features:
Copy- Server-side copy of filesMove- Server-side move/rename of filesDirMove- Server-side move of directoriesListR- Recursive listing for--fast-listAbout- Storage quota informationPurge- Delete directory and all contentsCleanUp- Empty the trashUserInfo- Get user account informationMetadata- Read and write file metadata/propertiesChangeNotify- Poll for remote changes (used byrclone mountandrclone rc vfs/poll-interval)
Integration with other services
Huawei Drive can be used as a backend for various rclone operations:
- Mount as a local filesystem using
rclone mount - Serve over HTTP using
rclone serve http - Serve over FTP using
rclone serve ftp - Serve over WebDAV using
rclone serve webdav
Note that some operations may be slower than local storage due to API limitations and network latency.