All Products
Search
Document Center

File Storage NAS:CreateFile

Last Updated:Aug 26, 2026

Creates a directory or file.

Operation description

  • This operation is available only to specific users.

  • Only General-purpose NAS file systems that use the SMB Protocol Type and have access control enabled are supported. Alibaba Cloud Key Management Service (KMS) must also be activated.

Prerequisites

Before calling this API to create a file, complete the following four steps:

  1. Create an SMB General-purpose NAS file system: Call the CreateFileSystem operation with ProtocolType set to SMB to create a General-purpose NAS file system that supports the SMB protocol.

  2. Activate KMS: Activate KMS by using one of the following methods:

  3. Enable SMB ACL: Call the EnableSmbAcl operation to enable the SMB ACL feature. Recommended configuration:

    • AuthMethod=NTLM

    • AuthCenter=EDS

    • This configuration does not require an AD domain Keytab and is easier to use.

  4. Call CreateFile: After completing the preceding steps, call this operation to create a directory or file.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

nas:CreateFile

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

FileSystemId

string

Yes

The file system ID.

1ca404****

Path

string

Yes

The absolute path of the directory or file.

  • The path must start and end with a forward slash (/).

  • The path must be 1 to 1,023 characters in length.

  • The path must be encoded in UTF-8.

/test/

Type

string

Yes

The object type. Valid values:

  • File: file.

  • Directory: directory.

File

Owner

string

No

The portable account ID. Limit: The value is a 16-character string that supports digits and lowercase letters.

378cc7630f26****

OwnerAccessInheritable

boolean

No

Specifies whether to share directory permissions. Valid values:

  • false (default): does not share directory permissions.

  • true: shares directory permissions.

Note
  • This parameter takes effect only when Type is set to Directory and Owner is not empty.

  • The directory has inheritable Owner permissions. The Owner has read and write permissions on subdirectories and files created under this directory, even if they are created by other users.

false

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID.

2D69A58F-345C-4FDE-88E4-BF518948****

Examples

Success response

JSON format

{
  "RequestId": "2D69A58F-345C-4FDE-88E4-BF518948****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.