Copied.
Browser-based Upload (POST)
Scenarios
If the size of an object, such as a text file, image, or video, to be uploaded is smaller than 5 GB, you can use browser-based upload (POST).
POST passes data as form fields in the request body. You need to specify bucket domain name in the URL. An example request is as follows:
POST / HTTP/1.1

OBS allows you to upload objects to buckets in a specified region, but Huawei Cloud does not detect the object content you uploaded. If your object uploads involve cross-border transfer, ensure that your use complies with relevant laws and regulations.
Prerequisites
- You have the write permissions to a bucket.
- If you want to classify files, you can create folders and upload files to different folders. For details, see Creating a Folder.
Constraints
Size and number of objects
- If a file is smaller than 5 GB, use simple upload. To upload a file larger than 5 GB, refer to Multipart Upload.
- You can specify a quota for a bucket to limit its storage capacity. For details, see Managing Bucket Quotas.
Object naming
See Guidelines on Naming Object Keys.
Batch operations
- The bucket is in CN-Hong Kong, AP-Bangkok, or AP-Singapore.
- The bucket version is 3.0. To view a bucket version, see Checking OBS Version (OBS 2.0 or OBS 3.0).
Folder uploads
You can upload folders using OBS Console, OBS Browser+, or obsutil.
Other
- Versioning is not enabled for a bucket:
- If you upload a new file with the same name as the one in the bucket, the new file will automatically overwrite the previous one and the ACL information of the previous file will not be retained.
- If you upload a new folder with the same name as the one in the bucket, the two folders will be merged, and files in the new folder will overwrite those with the same name in the previous folder.
- Versioning is enabled for a bucket: If you upload a new file with the same name as the one you previously uploaded to the bucket, a new file version will be added to the bucket. For details, see Versioning.
Ways to Upload
You can use OBS Console, APIs, SDKs, OBS Browser+, or obsutil to upload objects.
Using OBS Console
- In the navigation pane of OBS Console, choose Object Storage.
- In the bucket list, click the bucket you want to operate. The Objects page is displayed.
- On the object list page, click Upload Object.
You can also go to the folder that the file is to be uploaded to and click Upload Object.
Batch upload is used as an example here. If a region only supports single upload, follow the on-screen instructions.
If the files that you want to upload to OBS are stored in Microsoft OneDrive, it is recommended that the names of these files contain a maximum of 32 characters to ensure compatibility.
Figure 1 Uploading objects - Select a storage class. If you do not specify a storage class, the objects you upload inherit the default storage class of the bucket.
An object can have a different storage class from its bucket. By default, an object inherits the storage class of the bucket where it is uploaded. You can specify a storage class for an object when uploading it, or you can change the object storage class after the object is uploaded.
- Drag and drop the files or folders you want to upload to the Upload Object area.
You can also click add files in the Upload Object area to select files.
- Server-Side Encryption: Disable it or choose SSE-KMS or SSE-OBS. For details, see Server-Side Encryption Overview.
If your bucket has server-side encryption enabled, you can select Inherit from bucket when uploading an object.
- (Optional) To configure WORM retention policies, object tags, or metadata, click Next: (Optional) Configure Advanced Settings.
WORM retention policies can be configured in the advanced settings only when WORM is enabled for the bucket.
Configuring metadata: Add metadata ContentDisposition, ContentLanguage, WebsiteRedirectLocation, ContentEncoding, or ContentType as needed. For more information, see OBS Metadata. Metadata is a set of name-value pairs. The metadata value cannot be left blank. You can add multiple metadata entries by clicking Add.
Configuring WORM retention: Choose Inherit from bucket, or choose Configure and then specify a retention period, to automatically protect new objects uploaded to the bucket from being deleted.
Configuring tags: Tags are used to identify objects with tag keys and values. For details, see Adding Tags to an Object.
Figure 2 Configuring metadata or WORM retention - Click Upload.
Using APIs
Using the GUI Tool - OBS Browser+
- Log in to OBS Browser+.
- Click the bucket where you want to upload files or folders.
- Click Upload and then Add File or Folder, as shown in Figure 3.
For better experience when using the Add File function, you are advised to upload a maximum of 100 files at a time. If you need to upload more, place all the files in a folder and upload them by adding a folder.
- If message "Service Unavailable" is displayed when files are being uploaded, try again later.
- If an access deny message is displayed when you are uploading a file or folder, possible causes are as follows:
- Access to the bucket is restricted by an ACL. For example, you do not have the write permission for the bucket.
- Access to the bucket is restricted by a bucket policy. For example, you do not have the write permission for the bucket, or write operations cannot be performed on the bucket during the current period.
If such message is displayed, check ACL and policy settings of the bucket and resolve the problem accordingly.
You must have access to the file you want to upload, or the file upload will fail.
- In the displayed dialog box, select the file or folder you want to upload and click Open.
You can upload one folder or multiple files at a time. To upload multiple files, hold down Ctrl or Shift to select multiple files and batch upload them. You can also press Ctrl+A to select all files. The operations are consistent with those in Windows operating systems.
- Click OK.
Using the CLI Tool - obsutil
Command Line Structure
- In Windows
- Uploading a file
obsutil cp file_url obs://bucket[/key] [-arcDir=xxx] [-dryRun] [-link] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=5248800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-o=xxx] [-cpd=xxx] [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Uploading a folder
obsutil cp folder_url obs://bucket[/key] -r [-arcDir=xxx] [-dryRun] [-link] [-f] [-flat] [-u] [-vlength] [-vmd5] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Uploading multiple files/folders
obsutil cp file1_url,folder1_url|filelist_url obs://bucket[/prefix] -msm=1 [-r] [-arcDir=xxx] [-dryRun] [-link] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx][-timeRange=time1-time2] [-at] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In this command, /prefix is the name prefix for uploading folders. For the execution examples, see Upload.
- Uploading a file
- In Linux or macOS
- Uploading a file
./obsutil cp file_url obs://bucket[/key] [-arcDir=xxx] [-dryRun] [-link] [-u] [-vlength] [-vmd5] [-p=1] [-threshold=5248800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-o=xxx] [-cpd=xxx] [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Uploading a folder
./obsutil cp folder_url obs://bucket[/key] -r [-arcDir=xxx] [-dryRun] [-link] [-f] [-flat] [-u] [-vlength] [-vmd5] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-at] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- Uploading multiple files/folders
./obsutil cp file1_url,folder1_url|filelist_url obs://bucket[/prefix] -msm=1 [-r] [-arcDir=xxx] [-dryRun] [-link] [-f] [-u] [-vlength] [-vmd5] [-flat] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx][-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In this command, /prefix is the name prefix for uploading folders. For the execution examples, see Upload.
- Uploading a file
Examples
- Take the Windows OS as an example. Run the obsutil cp d:\temp\test.txt obs://bucket-test/key command to upload the test.txt file in the temp directory in the D: drive to bucket bucket-test and rename the file as key.
obsutil cp d:\temp\test.txt obs://bucket-test/key Start at 2024-09-30 08:11:41.6724827 +0000 UTC Parallel: 5 Jobs: 5 Threshold: 50.00MB PartSize: auto VerifyLength: false VerifyMd5: false CheckpointDir: C:\Users\Administrator\.obsutil_checkpoint [====================================================] 100.00% 1.68 MB/s 8.46MB/8.46MB 5s Upload successfully, 8.46MB, n/a, d:\temp\test.txt --> obs://bucket-test/key, cost [5], status [200], request id [0000016979E1D2B2860BB5181229C72C]
- Take the Windows OS as an example. Run the obsutil cp d:\temp obs://bucket-test -f -r command to recursively upload all files and subfolders in the temp directory in the D: drive to the temp folder in bucket bucket-test.
obsutil cp d:\temp obs://bucket-test -f -r Start at 2024-09-30 08:14:12.1406275 +0000 UTC Parallel: 5 Jobs: 5 Threshold: 50.00MB PartSize: auto VerifyLength: false VerifyMd5: false CheckpointDir: C:\Users\Administrator\.obsutil_checkpoint Task id: 104786c8-27c2-48fc-bc6a-5886596fb0ed OutputDir: C:\Users\Administrator\.obsutil_output [========================================================] 100.00% tps:35.71 2.02 KB/s 7.20MB/7.20MB 0s Succeed count: 5 Failed count: 0 Succeed bytes: xxx Metrics [max cost:90 ms, min cost:45 ms, average cost:63.80 ms, average tps:35.71, transferred size: 7.20MB] Task id: 104786c8-27c2-48fc-bc6a-5886596fb0ed
- For more examples, see Upload.
Parameter Description
Parameter |
Optional or Mandatory |
Description |
---|---|---|
file_url |
Optional for uploading multiple files/folders Mandatory for uploading a file |
The local file path
|
folder_url |
Optional for uploading multiple files/folders Mandatory for uploading a folder |
The local folder path
|
filelist_url |
Optional for uploading multiple files/folders |
The path of the file that contains the list of files/folders to be uploaded. If this parameter is configured, msm must be set to 2. |
bucket |
Mandatory |
The name of the bucket where you will upload the file or folder |
key |
Optional |
The object name or object name prefix specified when uploading a file, or the object name prefix specified when uploading a folder When uploading a file or folder, the upload path and name change depending on the value of this parameter. The specific rules are as follows:
NOTE:
For details about how to use this parameter, see Upload. |
fr |
Optional for uploading a file (additional parameter) |
Generates an operation result file when uploading a file. |
flat |
Optional for uploading a folder or multiple files/folders (additional parameter) |
Uploads all files in a folder but not the folder itself. |
arcDir |
Optional (additional parameter) |
The path to which the uploaded files are archived |
dryRun |
Optional (additional parameter) |
Conducts a dry run. |
link |
Optional (additional parameter) |
The actual path of a symbolic link for a file or folder
|
u |
Optional (additional parameter) |
Indicates incremental upload. If this parameter is set, each file can be uploaded only when it does not exist in the bucket, its size is different from the namesake one in the bucket, or it has the latest modification time. When you compare each local file with data in the bucket, a billable HEAD request is generated. For details, see Requests. |
vlength |
Optional (additional parameter) |
After the upload completes, checks whether the sizes of the objects in the bucket are the same as those of the local files. |
vmd5 |
Optional (additional parameter) |
After the upload completes, checks whether the MD5 values of the objects in the bucket are the same as those of the local files.
|
p |
Optional (additional parameter) |
The maximum number of concurrent uploads for a multipart upload The default value is the value of defaultParallels in the configuration file. |
threshold |
Optional (additional parameter) |
The threshold for enabling multipart upload. If the size of the file or folder to be uploaded is smaller than the threshold, upload it directly. Otherwise, a multipart upload is required. The default value is the value of defaultBigfileThreshold in the configuration file. Unit: byte This parameter value can contain a unit, for example, 1MB (indicating 1,048,576 bytes).
NOTE:
If you upload a file or folder directly, no part record is generated, and resumable transmission is not supported. |
acl |
Optional (additional parameter) |
The access control policies that can be specified for objects when uploading files. Possible values are:
|
sc |
Optional (additional parameter) |
The storage classes of objects that can be specified when uploading files Possible values are:
|
meta |
Optional (additional parameter) |
The standard or user-defined metadata that can be specified during file upload
|
ps |
Optional (additional parameter) |
The size of each part in a multipart upload task
|
cpd |
Optional (additional parameter) |
The folder where the part records reside. The default value is .obsutil_checkpoint, the subfolder in the home directory of the user who executes obsutil commands. A part record is generated during a multipart upload and saved to the upload subfolder. After the upload succeeds, its part record is deleted automatically. If the upload fails or is suspended, the system attempts to resume the task according to its part record when you perform the upload the next time. |
r |
Mandatory for uploading a folder (additional parameter) Optional for uploading multiple files/folders |
Recursively uploads all files and subfolders within a folder. |
f |
Optional for uploading a folder or multiple files/folders (additional parameter) |
Runs in force mode. |
j |
Optional for uploading a folder or multiple files/folders (additional parameter) |
The maximum number of concurrent tasks for uploading a folder. The default value is the value of defaultJobs in the configuration file.
NOTE:
The value is ensured to be greater than or equal to 1. |
msm |
Mandatory for uploading multiple files/folders (additional parameter) |
Enables the mode for uploading multiple files/folders. Possible values are 1 and 2.
|
exclude |
Optional for uploading a folder or multiple files/folders (additional parameter) |
The file matching patterns that are excluded. After this parameter is specified, if the name of the file to be uploaded matches the value of this parameter, the file is skipped. For example, if this parameter is set to *.txt, all files whose names end with .txt are skipped and not uploaded.
Restrictions: The matching pattern takes effect only for files in the folder.
NOTE:
|
include |
Optional for uploading a folder or multiple files/folders (additional parameter) |
The file matching patterns that are included. After this parameter is specified, if the name of the file to be uploaded matches the value of this parameter, the file is uploaded. For example, if this parameter is set to *.txt, all files whose names end with .txt are uploaded.
Restrictions:
Example: ./obsutil cp /localpath/ obs://test/ -include=/localpath/2022-12-09/* -f -r This command uploads files that are under localpath and start with /localpath/2022-12-09/ to bucket test.
NOTE:
|
at |
Optional for uploading a folder or multiple files/folders (additional parameter) |
Indicates that only the files whose latest access time is within the value of timeRange are uploaded. This parameter must be used together with timeRange. |
disableDirObject |
Optional for uploading multiple folders (additional parameter) |
Indicates the folders themselves are not uploaded as an object. Configuring this parameter can avoid uploading empty folders to a bucket. If a folder contains files, the files will be uploaded and the original path format is retained. |
timeRange |
Optional for uploading a folder or multiple files/folders (additional parameter) |
The time range matching pattern when uploading files. Only files whose latest modification time is within the configured time range are uploaded. This pattern has a lower priority than the file matching patterns (exclude/include). That is, the time range matching pattern is executed after the configured file matching patterns.
|
mf |
Optional (additional parameter) |
Indicates that the name matching pattern (include or exclude) and the time matching pattern (timeRange) also take effect on folders. |
o |
Optional (additional parameter) |
The folder that stores the result files. After the command is executed, result files (possibly success, failure, and warning files) will be created in the specified folder. The default value is .obsutil_output, a subfolder in the user's home directory where obsutil commands are executed.
|
config |
Optional (additional parameter) |
The user-defined configuration file for executing the current command. To learn the parameters that can be configured in this file, see Configuration Parameters. |
e |
Optional (additional parameter) |
The endpoint |
i |
Optional (additional parameter) |
The user's AK |
k |
Optional (additional parameter) |
The user's SK |
t |
Optional (additional parameter) |
The user's security token |
Response
Field |
Description |
---|---|
Parallel |
The parameter -p in the request |
Jobs |
The parameter -j in the request |
Threshold |
The parameter -threshold in the request |
PartSize |
The parameter -ps in the request |
Exclude |
The parameter -exclude in the request |
Include |
The parameter -include in the request |
TimeRange |
The parameter -timeRange in the request |
VerifyLength |
The parameter -vlength in the request |
VerifyMd5 |
The parameter -vmd5 in the request |
CheckpointDir |
The parameter -cpd in the request |
OutputDir |
The parameter -o in the request |
ArcDir |
The parameter -arcDir in the request |
Succeed count |
The number of successful tasks |
Failed count |
The number of failed tasks |
Skip count |
The number of tasks that are skipped during incremental upload, download, or copy, and synchronous upload, download, or copy.
NOTE:
Skipped tasks are recorded into successful tasks. |
Warning count |
The number of tasks that are executed successfully but contain warnings.
NOTE:
|
Succeed bytes |
The number of bytes that are successfully uploaded or downloaded. |
max cost |
The maximum duration of all tasks, in ms |
min cost |
The minimum duration of all tasks, in ms |
average cost |
The average duration of all tasks, in ms |
average tps |
The average number of tasks completed per second |
Task id |
The unique ID of an operation, which is used to search for the result file generated for a batch task |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot