From 5b25ae292f085da66cfe5f96072b1784a7839f9f Mon Sep 17 00:00:00 2001 From: weihongmin1 Date: Thu, 28 Aug 2025 11:35:03 +0000 Subject: [PATCH] OBS JAVA SDK 0708 Version Reviewed-by: Sabelnikov, Dmitriy Co-authored-by: weihongmin1 Co-committed-by: weihongmin1 --- docs/obs_3rd_party/java_sdk/ALL_META.TXT.json | 2775 +++++++++++++++++ docs/obs_3rd_party/java_sdk/CLASS.TXT.json | 1316 ++++++++ docs/obs_3rd_party/java_sdk/PARAMETERS.txt | 3 + .../java_sdk/en-us_image_0000001580082852.png | Bin 0 -> 4881 bytes .../java_sdk/en-us_image_0000001809221937.png | Bin 0 -> 22593 bytes docs/obs_3rd_party/java_sdk/obs_21_0001.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_0002.html | 689 ++++ docs/obs_3rd_party/java_sdk/obs_21_0100.html | 663 ++++ docs/obs_3rd_party/java_sdk/obs_21_0101.html | 10 + docs/obs_3rd_party/java_sdk/obs_21_0102.html | 19 + docs/obs_3rd_party/java_sdk/obs_21_0200.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_0201.html | 65 + docs/obs_3rd_party/java_sdk/obs_21_0202.html | 737 +++++ docs/obs_3rd_party/java_sdk/obs_21_0204.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_0300.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_0301.html | 63 + docs/obs_3rd_party/java_sdk/obs_21_0302.html | 196 ++ docs/obs_3rd_party/java_sdk/obs_21_0303.html | 69 + docs/obs_3rd_party/java_sdk/obs_21_0400.html | 43 + docs/obs_3rd_party/java_sdk/obs_21_0401.html | 925 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0402.html | 726 +++++ docs/obs_3rd_party/java_sdk/obs_21_0403.html | 183 ++ docs/obs_3rd_party/java_sdk/obs_21_0404.html | 165 + docs/obs_3rd_party/java_sdk/obs_21_0405.html | 404 +++ docs/obs_3rd_party/java_sdk/obs_21_0406.html | 927 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0407.html | 204 ++ docs/obs_3rd_party/java_sdk/obs_21_0408.html | 190 ++ docs/obs_3rd_party/java_sdk/obs_21_0409.html | 208 ++ docs/obs_3rd_party/java_sdk/obs_21_0410.html | 227 ++ docs/obs_3rd_party/java_sdk/obs_21_0411.html | 309 ++ docs/obs_3rd_party/java_sdk/obs_21_0412.html | 457 +++ docs/obs_3rd_party/java_sdk/obs_21_0413.html | 168 + docs/obs_3rd_party/java_sdk/obs_21_0414.html | 175 ++ docs/obs_3rd_party/java_sdk/obs_21_0415.html | 176 ++ docs/obs_3rd_party/java_sdk/obs_21_0416.html | 202 ++ docs/obs_3rd_party/java_sdk/obs_21_0417.html | 405 +++ docs/obs_3rd_party/java_sdk/obs_21_0418.html | 389 +++ docs/obs_3rd_party/java_sdk/obs_21_0419.html | 377 +++ docs/obs_3rd_party/java_sdk/obs_21_0420.html | 208 ++ docs/obs_3rd_party/java_sdk/obs_21_0421.html | 21 + docs/obs_3rd_party/java_sdk/obs_21_0600.html | 31 + docs/obs_3rd_party/java_sdk/obs_21_0601.html | 14 + docs/obs_3rd_party/java_sdk/obs_21_0602.html | 1525 +++++++++ docs/obs_3rd_party/java_sdk/obs_21_0603.html | 1322 ++++++++ docs/obs_3rd_party/java_sdk/obs_21_0604.html | 343 ++ docs/obs_3rd_party/java_sdk/obs_21_0605.html | 1317 ++++++++ docs/obs_3rd_party/java_sdk/obs_21_0606.html | 1738 +++++++++++ docs/obs_3rd_party/java_sdk/obs_21_0607.html | 29 + docs/obs_3rd_party/java_sdk/obs_21_0608.html | 1326 ++++++++ docs/obs_3rd_party/java_sdk/obs_21_0609.html | 1346 ++++++++ docs/obs_3rd_party/java_sdk/obs_21_0611.html | 1318 ++++++++ docs/obs_3rd_party/java_sdk/obs_21_0612.html | 388 +++ docs/obs_3rd_party/java_sdk/obs_21_0614.html | 19 + docs/obs_3rd_party/java_sdk/obs_21_0615.html | 1141 +++++++ docs/obs_3rd_party/java_sdk/obs_21_0616.html | 713 +++++ docs/obs_3rd_party/java_sdk/obs_21_0617.html | 424 +++ docs/obs_3rd_party/java_sdk/obs_21_0618.html | 248 ++ docs/obs_3rd_party/java_sdk/obs_21_0619.html | 236 ++ docs/obs_3rd_party/java_sdk/obs_21_0620.html | 692 ++++ docs/obs_3rd_party/java_sdk/obs_21_0621.html | 722 +++++ docs/obs_3rd_party/java_sdk/obs_21_0700.html | 27 + docs/obs_3rd_party/java_sdk/obs_21_0701.html | 117 + docs/obs_3rd_party/java_sdk/obs_21_0702.html | 976 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0703.html | 974 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0704.html | 299 ++ docs/obs_3rd_party/java_sdk/obs_21_0705.html | 962 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0706.html | 950 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0707.html | 985 ++++++ docs/obs_3rd_party/java_sdk/obs_21_0708.html | 333 ++ docs/obs_3rd_party/java_sdk/obs_21_0709.html | 740 +++++ docs/obs_3rd_party/java_sdk/obs_21_0800.html | 29 + docs/obs_3rd_party/java_sdk/obs_21_0801.html | 579 ++++ docs/obs_3rd_party/java_sdk/obs_21_0802.html | 841 +++++ docs/obs_3rd_party/java_sdk/obs_21_0803.html | 1472 +++++++++ docs/obs_3rd_party/java_sdk/obs_21_0804.html | 262 ++ docs/obs_3rd_party/java_sdk/obs_21_0805.html | 1576 ++++++++++ docs/obs_3rd_party/java_sdk/obs_21_0806.html | 777 +++++ docs/obs_3rd_party/java_sdk/obs_21_0807.html | 353 +++ docs/obs_3rd_party/java_sdk/obs_21_0808.html | 519 +++ docs/obs_3rd_party/java_sdk/obs_21_0809.html | 635 ++++ docs/obs_3rd_party/java_sdk/obs_21_0810.html | 627 ++++ docs/obs_3rd_party/java_sdk/obs_21_0900.html | 11 + docs/obs_3rd_party/java_sdk/obs_21_0901.html | 2671 ++++++++++++++++ docs/obs_3rd_party/java_sdk/obs_21_1000.html | 31 + docs/obs_3rd_party/java_sdk/obs_21_1001.html | 16 + docs/obs_3rd_party/java_sdk/obs_21_1002.html | 249 ++ docs/obs_3rd_party/java_sdk/obs_21_1003.html | 239 ++ docs/obs_3rd_party/java_sdk/obs_21_1004.html | 938 ++++++ docs/obs_3rd_party/java_sdk/obs_21_1005.html | 1193 +++++++ docs/obs_3rd_party/java_sdk/obs_21_1006.html | 295 ++ docs/obs_3rd_party/java_sdk/obs_21_1007.html | 1651 ++++++++++ docs/obs_3rd_party/java_sdk/obs_21_1008.html | 626 ++++ docs/obs_3rd_party/java_sdk/obs_21_1009.html | 263 ++ docs/obs_3rd_party/java_sdk/obs_21_1010.html | 505 +++ docs/obs_3rd_party/java_sdk/obs_21_1011.html | 432 +++ docs/obs_3rd_party/java_sdk/obs_21_1100.html | 17 + docs/obs_3rd_party/java_sdk/obs_21_1101.html | 17 + docs/obs_3rd_party/java_sdk/obs_21_1102.html | 757 +++++ docs/obs_3rd_party/java_sdk/obs_21_1103.html | 582 ++++ docs/obs_3rd_party/java_sdk/obs_21_1104.html | 199 ++ docs/obs_3rd_party/java_sdk/obs_21_1400.html | 17 + docs/obs_3rd_party/java_sdk/obs_21_1401.html | 18 + docs/obs_3rd_party/java_sdk/obs_21_1402.html | 399 +++ docs/obs_3rd_party/java_sdk/obs_21_1403.html | 310 ++ docs/obs_3rd_party/java_sdk/obs_21_1404.html | 199 ++ docs/obs_3rd_party/java_sdk/obs_21_1500.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_1501.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_1502.html | 724 +++++ docs/obs_3rd_party/java_sdk/obs_21_1503.html | 454 +++ docs/obs_3rd_party/java_sdk/obs_21_1600.html | 19 + docs/obs_3rd_party/java_sdk/obs_21_1601.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_1602.html | 1472 +++++++++ docs/obs_3rd_party/java_sdk/obs_21_1603.html | 780 +++++ docs/obs_3rd_party/java_sdk/obs_21_1604.html | 476 +++ docs/obs_3rd_party/java_sdk/obs_21_1605.html | 202 ++ docs/obs_3rd_party/java_sdk/obs_21_1700.html | 17 + docs/obs_3rd_party/java_sdk/obs_21_1701.html | 17 + docs/obs_3rd_party/java_sdk/obs_21_1702.html | 313 ++ docs/obs_3rd_party/java_sdk/obs_21_1703.html | 277 ++ docs/obs_3rd_party/java_sdk/obs_21_1704.html | 201 ++ docs/obs_3rd_party/java_sdk/obs_21_1900.html | 15 + docs/obs_3rd_party/java_sdk/obs_21_1901.html | 18 + docs/obs_3rd_party/java_sdk/obs_21_1902.html | 77 + docs/obs_3rd_party/java_sdk/obs_21_1903.html | 190 ++ docs/obs_3rd_party/java_sdk/obs_21_2000.html | 19 + docs/obs_3rd_party/java_sdk/obs_21_2001.html | 115 + docs/obs_3rd_party/java_sdk/obs_21_2002.html | 746 +++++ docs/obs_3rd_party/java_sdk/obs_21_2003.html | 38 + docs/obs_3rd_party/java_sdk/obs_21_2004.html | 87 + docs/obs_3rd_party/java_sdk/obs_21_2005.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2100.html | 41 + docs/obs_3rd_party/java_sdk/obs_21_2107.html | 12 + docs/obs_3rd_party/java_sdk/obs_21_2109.html | 14 + docs/obs_3rd_party/java_sdk/obs_21_2110.html | 12 + docs/obs_3rd_party/java_sdk/obs_21_2111.html | 36 + docs/obs_3rd_party/java_sdk/obs_21_2112.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2114.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2115.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2117.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2118.html | 14 + docs/obs_3rd_party/java_sdk/obs_21_2119.html | 100 + docs/obs_3rd_party/java_sdk/obs_21_2121.html | 161 + docs/obs_3rd_party/java_sdk/obs_21_2124.html | 1624 ++++++++++ docs/obs_3rd_party/java_sdk/obs_21_2202.html | 20 + docs/obs_3rd_party/java_sdk/obs_21_2301.html | 13 + docs/obs_3rd_party/java_sdk/obs_21_2302.html | 102 + docs/obs_3rd_party/java_sdk/obs_21_2303.html | 665 ++++ docs/obs_3rd_party/java_sdk/obs_23_1712.html | 14 + docs/obs_3rd_party/java_sdk/obs_23_1713.html | 124 + docs/obs_3rd_party/java_sdk/obs_23_1714.html | 116 + docs/obs_3rd_party/java_sdk/obs_23_1715.html | 124 + .../caution_3.0-en-us.png | Bin 0 -> 2752 bytes .../public_sys-resources/danger_3.0-en-us.png | Bin 0 -> 2771 bytes .../java_sdk/public_sys-resources/delta.gif | Bin 0 -> 836 bytes .../public_sys-resources/deltaend.gif | Bin 0 -> 834 bytes .../public_sys-resources/icon-arrowdn.gif | Bin 0 -> 1887 bytes .../public_sys-resources/icon-arrowrt.gif | Bin 0 -> 1890 bytes .../public_sys-resources/icon-caution.gif | Bin 0 -> 1086 bytes .../public_sys-resources/icon-danger.gif | Bin 0 -> 1086 bytes .../public_sys-resources/icon-huawei.gif | Bin 0 -> 2767 bytes .../public_sys-resources/icon-note.gif | Bin 0 -> 983 bytes .../public_sys-resources/icon-notice.gif | Bin 0 -> 962 bytes .../public_sys-resources/icon-tip.gif | Bin 0 -> 879 bytes .../public_sys-resources/icon-warning.gif | Bin 0 -> 1086 bytes .../public_sys-resources/note_3.0-en-us.png | Bin 0 -> 1080 bytes .../public_sys-resources/notice_3.0-en-us.png | Bin 0 -> 1672 bytes .../warning_3.0-en-us.png | Bin 0 -> 3164 bytes 167 files changed, 63873 insertions(+) create mode 100644 docs/obs_3rd_party/java_sdk/ALL_META.TXT.json create mode 100644 docs/obs_3rd_party/java_sdk/CLASS.TXT.json create mode 100644 docs/obs_3rd_party/java_sdk/PARAMETERS.txt create mode 100644 docs/obs_3rd_party/java_sdk/en-us_image_0000001580082852.png create mode 100644 docs/obs_3rd_party/java_sdk/en-us_image_0000001809221937.png create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0001.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0002.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0100.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0101.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0102.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0200.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0201.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0202.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0204.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0300.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0301.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0302.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0303.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0400.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0401.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0402.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0403.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0404.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0405.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0406.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0407.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0408.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0409.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0410.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0411.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0412.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0413.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0414.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0415.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0416.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0417.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0418.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0419.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0420.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0421.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0600.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0601.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0602.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0603.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0604.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0605.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0606.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0607.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0608.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0609.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0611.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0612.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0614.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0615.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0616.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0617.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0618.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0619.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0620.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0621.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0700.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0701.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0702.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0703.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0704.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0705.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0706.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0707.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0708.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0709.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0800.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0801.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0802.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0803.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0804.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0805.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0806.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0807.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0808.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0809.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0810.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0900.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_0901.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1000.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1001.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1002.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1003.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1004.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1005.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1006.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1007.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1008.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1009.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1010.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1011.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1100.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1101.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1102.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1103.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1104.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1400.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1401.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1402.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1403.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1404.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1500.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1501.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1502.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1503.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1600.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1601.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1602.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1603.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1604.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1605.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1700.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1701.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1702.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1703.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1704.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1900.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1901.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1902.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_1903.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2000.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2001.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2002.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2003.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2004.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2005.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2100.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2107.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2109.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2110.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2111.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2112.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2114.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2115.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2117.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2118.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2119.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2121.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2124.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2202.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2301.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2302.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_21_2303.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_23_1712.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_23_1713.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_23_1714.html create mode 100644 docs/obs_3rd_party/java_sdk/obs_23_1715.html create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/caution_3.0-en-us.png create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/danger_3.0-en-us.png create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/delta.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/deltaend.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowdn.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowrt.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-caution.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-danger.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-huawei.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-note.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-notice.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-tip.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/icon-warning.gif create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/note_3.0-en-us.png create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/notice_3.0-en-us.png create mode 100644 docs/obs_3rd_party/java_sdk/public_sys-resources/warning_3.0-en-us.png diff --git a/docs/obs_3rd_party/java_sdk/ALL_META.TXT.json b/docs/obs_3rd_party/java_sdk/ALL_META.TXT.json new file mode 100644 index 000000000..013f1ec15 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/ALL_META.TXT.json @@ -0,0 +1,2775 @@ +[ + { + "dockw":"Developer Guide (Java SDK)" + }, + { + "uri":"obs_21_0101.html", + "node_id":"obs_21_0101.xml", + "product_code":"obs", + "code":"1", + "des":"This section describes version compatibility and important notes about Object Storage Service (OBS) SDK for Java.Recommended JDK versions: JDK 8 or laterThird-party depen", + "doc_type":"sdk-java-devg", + "kw":"Before You Start,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Before You Start", + "githuburl":"" + }, + { + "uri":"obs_21_0002.html", + "node_id":"obs_21_0002.xml", + "product_code":"obs", + "code":"2", + "des":"Table 1 lists the bucket-related APIs.Table 2lists object-related APIs.Table 3 lists the APIs related to temporarily authorized access.Table 4 lists the APIs related to v", + "doc_type":"sdk-java-devg", + "kw":"API Overview,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"API Overview", + "githuburl":"" + }, + { + "uri":"obs_21_0102.html", + "node_id":"obs_21_0102.xml", + "product_code":"obs", + "code":"3", + "des":"Before using OBS SDK for Java to access OBS, you need to prepare the service and development environments. To prepare the service environment, you will need an account an", + "doc_type":"sdk-java-devg", + "kw":"Preparations,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Preparations", + "githuburl":"" + }, + { + "uri":"obs_21_0001.html", + "node_id":"obs_21_0001.xml", + "product_code":"obs", + "code":"4", + "des":"Latest version of OBS Java SDK: DownloadYou can download the source code of SDK for Java and compile the source code to create a JAR package. Before using this method, en", + "doc_type":"sdk-java-devg", + "kw":"SDK Download and Installation,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"SDK Download and Installation", + "githuburl":"" + }, + { + "uri":"obs_21_0100.html", + "node_id":"obs_21_0100.xml", + "product_code":"obs", + "code":"5", + "des":"This section introduces how to use OBS SDK for Java to perform some basic actions, such as creating a bucket, and uploading, downloading, listing, and deleting objects.En", + "doc_type":"sdk-java-devg", + "kw":"Getting Started,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Getting Started", + "githuburl":"" + }, + { + "uri":"obs_21_0200.html", + "node_id":"obs_21_0200.xml", + "product_code":"obs", + "code":"6", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Initialization", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Initialization", + "githuburl":"" + }, + { + "uri":"obs_21_0201.html", + "node_id":"obs_21_0201.xml", + "product_code":"obs", + "code":"7", + "des":"After the SDK is installed, you need to create and configure an OBS client and configure the logging for the SDK to complete the initialization.", + "doc_type":"sdk-java-devg", + "kw":"Overview,Initialization,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_0202.html", + "node_id":"obs_21_0202.xml", + "product_code":"obs", + "code":"8", + "des":"This section describes how to create and configure an OBS client. If you already have a client, skip this section and obtain the API details by referring to API Overview.", + "doc_type":"sdk-java-devg", + "kw":"Creating and Configuring an OBS Client,Initialization,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Creating and Configuring an OBS Client", + "githuburl":"" + }, + { + "uri":"obs_21_0204.html", + "node_id":"obs_21_0204.xml", + "product_code":"obs", + "code":"9", + "des":"OBS SDK for Java offers logging based on the open-source Apache Log4j 2 library. By default, the SDK stores WARN log files to the directory specified by the JDK system va", + "doc_type":"sdk-java-devg", + "kw":"Configuring SDK Logging,Initialization,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring SDK Logging", + "githuburl":"" + }, + { + "uri":"obs_21_0400.html", + "node_id":"obs_21_0400.xml", + "product_code":"obs", + "code":"10", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Bucket Management", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Bucket Management", + "githuburl":"" + }, + { + "uri":"obs_21_0401.html", + "node_id":"obs_21_0401.xml", + "product_code":"obs", + "code":"11", + "des":"This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.When creating a bucket, you can also configure parameters such a", + "doc_type":"sdk-java-devg", + "kw":"Creating a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Creating a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0402.html", + "node_id":"obs_21_0402.xml", + "product_code":"obs", + "code":"12", + "des":"OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current ", + "doc_type":"sdk-java-devg", + "kw":"Obtaining a Bucket List,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining a Bucket List", + "githuburl":"" + }, + { + "uri":"obs_21_0403.html", + "node_id":"obs_21_0403.xml", + "product_code":"obs", + "code":"13", + "des":"This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 min", + "doc_type":"sdk-java-devg", + "kw":"Deleting a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0404.html", + "node_id":"obs_21_0404.xml", + "product_code":"obs", + "code":"14", + "des":"This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.To check whether a bucke", + "doc_type":"sdk-java-devg", + "kw":"Checking Whether a Bucket Exists,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Checking Whether a Bucket Exists", + "githuburl":"" + }, + { + "uri":"obs_21_0405.html", + "node_id":"obs_21_0405.xml", + "product_code":"obs", + "code":"15", + "des":"This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.To obtain bucket metadata, you must be the bucket owne", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Bucket Metadata,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Bucket Metadata", + "githuburl":"" + }, + { + "uri":"obs_21_0406.html", + "node_id":"obs_21_0406.xml", + "product_code":"obs", + "code":"16", + "des":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "doc_type":"sdk-java-devg", + "kw":"Setting a Bucket ACL,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Setting a Bucket ACL", + "githuburl":"" + }, + { + "uri":"obs_21_0412.html", + "node_id":"obs_21_0412.xml", + "product_code":"obs", + "code":"17", + "des":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "doc_type":"sdk-java-devg", + "kw":"Obtaining a Bucket ACL,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining a Bucket ACL", + "githuburl":"" + }, + { + "uri":"obs_21_0407.html", + "node_id":"obs_21_0407.xml", + "product_code":"obs", + "code":"18", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-java-devg", + "kw":"Configuring a Bucket Policy,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring a Bucket Policy", + "githuburl":"" + }, + { + "uri":"obs_21_0413.html", + "node_id":"obs_21_0413.xml", + "product_code":"obs", + "code":"19", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Policy of a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Policy of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0414.html", + "node_id":"obs_21_0414.xml", + "product_code":"obs", + "code":"20", + "des":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "doc_type":"sdk-java-devg", + "kw":"Deleting a Bucket Policy,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting a Bucket Policy", + "githuburl":"" + }, + { + "uri":"obs_21_0408.html", + "node_id":"obs_21_0408.xml", + "product_code":"obs", + "code":"21", + "des":"This API returns the region where a bucket is located.To obtain the region of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucket", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Region of a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Region of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0409.html", + "node_id":"obs_21_0409.xml", + "product_code":"obs", + "code":"22", + "des":"This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.OBS measures bucket storage stat", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Storage Information of a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Storage Information of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0410.html", + "node_id":"obs_21_0410.xml", + "product_code":"obs", + "code":"23", + "des":"A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number", + "doc_type":"sdk-java-devg", + "kw":"Configuring a Storage Quota,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring a Storage Quota", + "githuburl":"" + }, + { + "uri":"obs_21_0415.html", + "node_id":"obs_21_0415.xml", + "product_code":"obs", + "code":"24", + "des":"This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.A bucket quota mus", + "doc_type":"sdk-java-devg", + "kw":"Obtaining a Bucket Storage Quota,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining a Bucket Storage Quota", + "githuburl":"" + }, + { + "uri":"obs_21_0411.html", + "node_id":"obs_21_0411.xml", + "product_code":"obs", + "code":"25", + "des":"This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object ", + "doc_type":"sdk-java-devg", + "kw":"Configuring a Storage Class for a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring a Storage Class for a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0416.html", + "node_id":"obs_21_0416.xml", + "product_code":"obs", + "code":"26", + "des":"This API returns the storage class of a bucket.To obtain a bucket's storage class, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStora", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Storage Class of a Bucket,Bucket Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Storage Class of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_0421.html", + "node_id":"obs_21_0421.xml", + "product_code":"obs", + "code":"27", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Bucket Inventory", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Bucket Inventory", + "githuburl":"" + }, + { + "uri":"obs_21_0417.html", + "node_id":"obs_21_0417.xml", + "product_code":"obs", + "code":"28", + "des":"This API configures an inventory rule for the bucket. With this API, object information in a bucket (source) is regularly listed and saved as CSV files. These files are t", + "doc_type":"sdk-java-devg", + "kw":"Configuring an Inventory Rule,Bucket Inventory,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring an Inventory Rule", + "githuburl":"" + }, + { + "uri":"obs_21_0418.html", + "node_id":"obs_21_0418.xml", + "product_code":"obs", + "code":"29", + "des":"This API returns an inventory rule (identified by configurationId) for the bucket.To obtain a bucket inventory rule, you must be the bucket owner or have the required per", + "doc_type":"sdk-java-devg", + "kw":"Obtaining an Inventory Rule,Bucket Inventory,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining an Inventory Rule", + "githuburl":"" + }, + { + "uri":"obs_21_0419.html", + "node_id":"obs_21_0419.xml", + "product_code":"obs", + "code":"30", + "des":"This API returns a list of all inventory rules for the bucket.To list inventory rules for a bucket, you must be the bucket owner or have the required permission (obs:buck", + "doc_type":"sdk-java-devg", + "kw":"Listing Inventory Rules,Bucket Inventory,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Listing Inventory Rules", + "githuburl":"" + }, + { + "uri":"obs_21_0420.html", + "node_id":"obs_21_0420.xml", + "product_code":"obs", + "code":"31", + "des":"This API deletes an inventory rule (identified by configurationId) from the bucket.To delete a bucket inventory rule, you must be the bucket owner or have the required pe", + "doc_type":"sdk-java-devg", + "kw":"Deleting an Inventory Rule,Bucket Inventory,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting an Inventory Rule", + "githuburl":"" + }, + { + "uri":"obs_21_0600.html", + "node_id":"obs_21_0600.xml", + "product_code":"obs", + "code":"32", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Object Upload", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Object Upload", + "githuburl":"" + }, + { + "uri":"obs_21_0601.html", + "node_id":"obs_21_0601.xml", + "product_code":"obs", + "code":"33", + "des":"In OBS, objects are basic data units that users can perform operations on. OBS Java SDK provides abundant APIs for object upload in the following methods:StreamingFile-ba", + "doc_type":"sdk-java-devg", + "kw":"Overview,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_0602.html", + "node_id":"obs_21_0602.xml", + "product_code":"obs", + "code":"34", + "des":"This API uploads a local fileto OBS over the Internet. These files can be texts, images, videos, or any other type of files.You can upload texts, images, videos, or any o", + "doc_type":"sdk-java-devg", + "kw":"Uploading an Object - Streaming,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading an Object - Streaming", + "githuburl":"" + }, + { + "uri":"obs_21_0603.html", + "node_id":"obs_21_0603.xml", + "product_code":"obs", + "code":"35", + "des":"This API uploads local filesto OBS over the Internet. The file to be uploaded can be of any type.To upload an object, you must be the bucket owner or have the required pe", + "doc_type":"sdk-java-devg", + "kw":"Uploading an Object - File-Based,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading an Object - File-Based", + "githuburl":"" + }, + { + "uri":"obs_21_0604.html", + "node_id":"obs_21_0604.xml", + "product_code":"obs", + "code":"36", + "des":"This API returns the upload progress of a specified object.You can call PutObjectRequest.setProgressListener to obtain the upload progress.To obtain the upload progress, ", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Upload Progress,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Upload Progress", + "githuburl":"" + }, + { + "uri":"obs_21_0605.html", + "node_id":"obs_21_0605.xml", + "product_code":"obs", + "code":"37", + "des":"This API creates a folder in an existing bucket to manage data in OBS.OBS does not involve folders like in a file system. All elements in buckets are objects. To create a", + "doc_type":"sdk-java-devg", + "kw":"Creating a Folder,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Creating a Folder", + "githuburl":"" + }, + { + "uri":"obs_21_0606.html", + "node_id":"obs_21_0606.xml", + "product_code":"obs", + "code":"38", + "des":"This API configures metadata for an object when uploading it. Object metadata include the object length, MIME type, MD5 value (for verification), storage class, and custo", + "doc_type":"sdk-java-devg", + "kw":"Configuring Object Metadata,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Object Metadata", + "githuburl":"" + }, + { + "uri":"obs_21_0607.html", + "node_id":"obs_21_0607.xml", + "product_code":"obs", + "code":"39", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Multipart Upload", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Multipart Upload", + "githuburl":"" + }, + { + "uri":"obs_21_0614.html", + "node_id":"obs_21_0614.xml", + "product_code":"obs", + "code":"40", + "des":"You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:Files to be uploaded are larger than 100 MB.The network con", + "doc_type":"sdk-java-devg", + "kw":"Multipart Upload Overview,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Multipart Upload Overview", + "githuburl":"" + }, + { + "uri":"obs_21_0615.html", + "node_id":"obs_21_0615.xml", + "product_code":"obs", + "code":"41", + "des":"This API initiates a multipart upload and returns a globally unique upload ID. You can use this upload ID in your subsequent requests including abortMultipartUpload, list", + "doc_type":"sdk-java-devg", + "kw":"Initiating a Multipart Upload,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Initiating a Multipart Upload", + "githuburl":"" + }, + { + "uri":"obs_21_0616.html", + "node_id":"obs_21_0616.xml", + "product_code":"obs", + "code":"42", + "des":"After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part", + "doc_type":"sdk-java-devg", + "kw":"Uploading a Part,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading a Part", + "githuburl":"" + }, + { + "uri":"obs_21_0617.html", + "node_id":"obs_21_0617.xml", + "product_code":"obs", + "code":"43", + "des":"This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, yo", + "doc_type":"sdk-java-devg", + "kw":"Assembling Parts,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Assembling Parts", + "githuburl":"" + }, + { + "uri":"obs_21_0618.html", + "node_id":"obs_21_0618.xml", + "product_code":"obs", + "code":"44", + "des":"Multipart upload is mainly used for large file upload or when the network connection is poor.You can use UploadPartRequest.setOffset and UploadPartRequest.setPartSize to ", + "doc_type":"sdk-java-devg", + "kw":"Code Example of a Multipart Upload,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Code Example of a Multipart Upload", + "githuburl":"" + }, + { + "uri":"obs_21_0619.html", + "node_id":"obs_21_0619.xml", + "product_code":"obs", + "code":"45", + "des":"This API aborts a multipart upload using the multipart upload ID.After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupie", + "doc_type":"sdk-java-devg", + "kw":"Aborting a Multipart Upload,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Aborting a Multipart Upload", + "githuburl":"" + }, + { + "uri":"obs_21_0620.html", + "node_id":"obs_21_0620.xml", + "product_code":"obs", + "code":"46", + "des":"This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.You can list the uploaded parts of a specified multipart upload", + "doc_type":"sdk-java-devg", + "kw":"Listing Uploaded Parts,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Listing Uploaded Parts", + "githuburl":"" + }, + { + "uri":"obs_21_0621.html", + "node_id":"obs_21_0621.xml", + "product_code":"obs", + "code":"47", + "des":"This API lists ongoing multipart uploads.Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of", + "doc_type":"sdk-java-devg", + "kw":"Listing Multipart Uploads,Multipart Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Listing Multipart Uploads", + "githuburl":"" + }, + { + "uri":"obs_21_0608.html", + "node_id":"obs_21_0608.xml", + "product_code":"obs", + "code":"48", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes. The object expiration time set using this API takes preced", + "doc_type":"sdk-java-devg", + "kw":"Configuring Lifecycle Rules,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Lifecycle Rules", + "githuburl":"" + }, + { + "uri":"obs_21_0609.html", + "node_id":"obs_21_0609.xml", + "product_code":"obs", + "code":"49", + "des":"This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.The appendObject operation adds data to ", + "doc_type":"sdk-java-devg", + "kw":"Uploading an Object - Append,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading an Object - Append", + "githuburl":"" + }, + { + "uri":"obs_21_0611.html", + "node_id":"obs_21_0611.xml", + "product_code":"obs", + "code":"50", + "des":"The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connec", + "doc_type":"sdk-java-devg", + "kw":"Uploading an Object - Resumable,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading an Object - Resumable", + "githuburl":"" + }, + { + "uri":"obs_21_0612.html", + "node_id":"obs_21_0612.xml", + "product_code":"obs", + "code":"51", + "des":"This API uploads an object up to 5 GB to a specified bucket in HTML form.You can call ObsClient.createPostSignature to generate request parameters for a browser-based upl", + "doc_type":"sdk-java-devg", + "kw":"Uploading an Object - Browser-Based,Object Upload,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Uploading an Object - Browser-Based", + "githuburl":"" + }, + { + "uri":"obs_21_0700.html", + "node_id":"obs_21_0700.xml", + "product_code":"obs", + "code":"52", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Object Download", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Object Download", + "githuburl":"" + }, + { + "uri":"obs_21_0701.html", + "node_id":"obs_21_0701.xml", + "product_code":"obs", + "code":"53", + "des":"OBS Java SDK provides abundant APIs for object download in the following methods:Streaming DownloadPartial DownloadResumable download", + "doc_type":"sdk-java-devg", + "kw":"Overview,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_0702.html", + "node_id":"obs_21_0702.xml", + "product_code":"obs", + "code":"54", + "des":"When you call ObsClient.getObject, an instance of ObsObject will be returned. This instance contains the contents of the object such as its name, attributes, input stream", + "doc_type":"sdk-java-devg", + "kw":"Downloading an Object - Streaming,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Downloading an Object - Streaming", + "githuburl":"" + }, + { + "uri":"obs_21_0703.html", + "node_id":"obs_21_0703.xml", + "product_code":"obs", + "code":"55", + "des":"This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are r", + "doc_type":"sdk-java-devg", + "kw":"Downloading an Object - Range-Based,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Downloading an Object - Range-Based", + "githuburl":"" + }, + { + "uri":"obs_21_0704.html", + "node_id":"obs_21_0704.xml", + "product_code":"obs", + "code":"56", + "des":"This API returns the download progress of a specified object.You can call GetObjectRequest.setProgressInterval to obtain the download progress.To obtain the download prog", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Download Progress,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Download Progress", + "githuburl":"" + }, + { + "uri":"obs_21_0705.html", + "node_id":"obs_21_0705.xml", + "product_code":"obs", + "code":"57", + "des":"This API returns the objects that meet one or more conditions. If there are no objects that meet the specified conditions, an error is returned.To download an object, you", + "doc_type":"sdk-java-devg", + "kw":"Downloading an Object - Conditional,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Downloading an Object - Conditional", + "githuburl":"" + }, + { + "uri":"obs_21_0706.html", + "node_id":"obs_21_0706.xml", + "product_code":"obs", + "code":"58", + "des":"This API rewrites the following HTTP/HTTPS response headers when downloading an object: Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition, and C", + "doc_type":"sdk-java-devg", + "kw":"Rewriting Response Headers,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Rewriting Response Headers", + "githuburl":"" + }, + { + "uri":"obs_21_0707.html", + "node_id":"obs_21_0707.xml", + "product_code":"obs", + "code":"59", + "des":"Object metadata is a set of key-value pairs that describe the object and is used for object management.This API returns the user-defined object metadata after the object ", + "doc_type":"sdk-java-devg", + "kw":"Obtaining User-defined Metadata,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining User-defined Metadata", + "githuburl":"" + }, + { + "uri":"obs_21_0708.html", + "node_id":"obs_21_0708.xml", + "product_code":"obs", + "code":"60", + "des":"Cold objects must first be restored before you can download them. Cold objects can be restored in either of the following ways.To restore a Cold object, you must be the b", + "doc_type":"sdk-java-devg", + "kw":"Restoring a Cold Object,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Restoring a Cold Object", + "githuburl":"" + }, + { + "uri":"obs_21_0709.html", + "node_id":"obs_21_0709.xml", + "product_code":"obs", + "code":"61", + "des":"Downloading large files often fails due to an unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download ", + "doc_type":"sdk-java-devg", + "kw":"Downloading an Object - Resumable,Object Download,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Downloading an Object - Resumable", + "githuburl":"" + }, + { + "uri":"obs_21_0800.html", + "node_id":"obs_21_0800.xml", + "product_code":"obs", + "code":"62", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Object Management", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Object Management", + "githuburl":"" + }, + { + "uri":"obs_21_0806.html", + "node_id":"obs_21_0806.xml", + "product_code":"obs", + "code":"63", + "des":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata is supported.There are", + "doc_type":"sdk-java-devg", + "kw":"Configuring Object Metadata,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Object Metadata", + "githuburl":"" + }, + { + "uri":"obs_21_0801.html", + "node_id":"obs_21_0801.xml", + "product_code":"obs", + "code":"64", + "des":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Users with the READ permission on objects can send HEAD requests t", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Object Metadata,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Object Metadata", + "githuburl":"" + }, + { + "uri":"obs_21_0802.html", + "node_id":"obs_21_0802.xml", + "product_code":"obs", + "code":"65", + "des":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "doc_type":"sdk-java-devg", + "kw":"Configuring an Object ACL,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring an Object ACL", + "githuburl":"" + }, + { + "uri":"obs_21_0808.html", + "node_id":"obs_21_0808.xml", + "product_code":"obs", + "code":"66", + "des":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "doc_type":"sdk-java-devg", + "kw":"Obtaining an Object ACL,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining an Object ACL", + "githuburl":"" + }, + { + "uri":"obs_21_0803.html", + "node_id":"obs_21_0803.xml", + "product_code":"obs", + "code":"67", + "des":"This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet", + "doc_type":"sdk-java-devg", + "kw":"Listing Objects,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Listing Objects", + "githuburl":"" + }, + { + "uri":"obs_21_0804.html", + "node_id":"obs_21_0804.xml", + "product_code":"obs", + "code":"68", + "des":"This API deletes objects from a specific bucket.To delete an object, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or Delet", + "doc_type":"sdk-java-devg", + "kw":"Deleting an Object,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting an Object", + "githuburl":"" + }, + { + "uri":"obs_21_0809.html", + "node_id":"obs_21_0809.xml", + "product_code":"obs", + "code":"69", + "des":"This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.In a batch delete operation, OBS concurrently deletes the specified object", + "doc_type":"sdk-java-devg", + "kw":"Batch Deleting Objects,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Batch Deleting Objects", + "githuburl":"" + }, + { + "uri":"obs_21_0805.html", + "node_id":"obs_21_0805.xml", + "product_code":"obs", + "code":"70", + "des":"This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.To co", + "doc_type":"sdk-java-devg", + "kw":"Copying an Object,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Copying an Object", + "githuburl":"" + }, + { + "uri":"obs_21_0810.html", + "node_id":"obs_21_0810.xml", + "product_code":"obs", + "code":"71", + "des":"This API allows you to upload a part by copying an object or part of this object.You can call ObsClient.copyPart to copy parts.To copy an object, you must be the bucket o", + "doc_type":"sdk-java-devg", + "kw":"Copying an Object - Multipart,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Copying an Object - Multipart", + "githuburl":"" + }, + { + "uri":"obs_21_0807.html", + "node_id":"obs_21_0807.xml", + "product_code":"obs", + "code":"72", + "des":"This API checks whether an object exists. If the returned HTTP status code is 200, the object exists. If the returned HTTP status code is 404, the object or bucket does n", + "doc_type":"sdk-java-devg", + "kw":"Checking Whether an Object Exists,Object Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Checking Whether an Object Exists", + "githuburl":"" + }, + { + "uri":"obs_21_0900.html", + "node_id":"obs_21_0900.xml", + "product_code":"obs", + "code":"73", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Temporarily Authorized Access", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Temporarily Authorized Access", + "githuburl":"" + }, + { + "uri":"obs_21_0901.html", + "node_id":"obs_21_0901.xml", + "product_code":"obs", + "code":"74", + "des":"ObsClient allows you to create a URL with Query parameters that carry authentication information by specifying the AK and SK, HTTP method, and request parameters. You can", + "doc_type":"sdk-java-devg", + "kw":"Accessing OBS Using a Signed URL,Temporarily Authorized Access,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Accessing OBS Using a Signed URL", + "githuburl":"" + }, + { + "uri":"obs_21_1000.html", + "node_id":"obs_21_1000.xml", + "product_code":"obs", + "code":"75", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Versioning", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Versioning", + "githuburl":"" + }, + { + "uri":"obs_21_1001.html", + "node_id":"obs_21_1001.xml", + "product_code":"obs", + "code":"76", + "des":"You can use versioning to store multiple versions of an object in a bucket.When versioning is enabled for a bucket, OBS keeps multiple versions of an object in the bucket", + "doc_type":"sdk-java-devg", + "kw":"Overview,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1002.html", + "node_id":"obs_21_1002.xml", + "product_code":"obs", + "code":"77", + "des":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "doc_type":"sdk-java-devg", + "kw":"Configuring Versioning for a Bucket,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Versioning for a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1003.html", + "node_id":"obs_21_1003.xml", + "product_code":"obs", + "code":"78", + "des":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Versioning Status of a Bucket,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Versioning Status of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1004.html", + "node_id":"obs_21_1004.xml", + "product_code":"obs", + "code":"79", + "des":"You can call ObsClient.getObject to obtain an object version by specifying the version ID (versionId).To download an object, you must be the bucket owner or have the requ", + "doc_type":"sdk-java-devg", + "kw":"Obtaining an Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining an Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1005.html", + "node_id":"obs_21_1005.xml", + "product_code":"obs", + "code":"80", + "des":"This API copies an object version in a specified bucket.You can call ObsClient.copyObject to copy an object version by specifying the version ID (versionId).To copy an ob", + "doc_type":"sdk-java-devg", + "kw":"Copying an Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Copying an Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1006.html", + "node_id":"obs_21_1006.xml", + "product_code":"obs", + "code":"81", + "des":"This API downloads a Cold object. To download such an object, you must restore it first. For the options for the restore speed, see Table 3.You can call ObsClient.restore", + "doc_type":"sdk-java-devg", + "kw":"Restoring a Specific Cold Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Restoring a Specific Cold Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1007.html", + "node_id":"obs_21_1007.xml", + "product_code":"obs", + "code":"82", + "des":"This API lists some or all of the object versions in a bucket. When listing the object versions, you can specify the criteria such as the prefix, number, and start positi", + "doc_type":"sdk-java-devg", + "kw":"Listing Object Versions,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Listing Object Versions", + "githuburl":"" + }, + { + "uri":"obs_21_1008.html", + "node_id":"obs_21_1008.xml", + "product_code":"obs", + "code":"83", + "des":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can set access control p", + "doc_type":"sdk-java-devg", + "kw":"Setting an ACL for an Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Setting an ACL for an Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1010.html", + "node_id":"obs_21_1010.xml", + "product_code":"obs", + "code":"84", + "des":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can call an ACL API to m", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the ACL of an Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the ACL of an Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1009.html", + "node_id":"obs_21_1009.xml", + "product_code":"obs", + "code":"85", + "des":"This API deletes an object from a specific bucket.You can call ObsClient.deleteObject to pass a version ID (versionId) to delete an object version.To delete an object, yo", + "doc_type":"sdk-java-devg", + "kw":"Deleting an Object Version,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting an Object Version", + "githuburl":"" + }, + { + "uri":"obs_21_1011.html", + "node_id":"obs_21_1011.xml", + "product_code":"obs", + "code":"86", + "des":"This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.In a batch delete operation, OBS concurrently deletes the specified object", + "doc_type":"sdk-java-devg", + "kw":"Batch Deleting Object Versions,Versioning,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Batch Deleting Object Versions", + "githuburl":"" + }, + { + "uri":"obs_21_1100.html", + "node_id":"obs_21_1100.xml", + "product_code":"obs", + "code":"87", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Lifecycle Management", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Lifecycle Management", + "githuburl":"" + }, + { + "uri":"obs_21_1101.html", + "node_id":"obs_21_1101.xml", + "product_code":"obs", + "code":"88", + "des":"OBS allows you to set lifecycle rules for buckets to automatically transition the storage class of an object or delete expired objects, to effectively use storage feature", + "doc_type":"sdk-java-devg", + "kw":"Overview,Lifecycle Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1102.html", + "node_id":"obs_21_1102.xml", + "product_code":"obs", + "code":"89", + "des":"This API configures lifecycle rules for a bucket to periodically delete objects in the bucket or transition objects between storage classes.An object will be automaticall", + "doc_type":"sdk-java-devg", + "kw":"Setting Lifecycle Rules,Lifecycle Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Setting Lifecycle Rules", + "githuburl":"" + }, + { + "uri":"obs_21_1103.html", + "node_id":"obs_21_1103.xml", + "product_code":"obs", + "code":"90", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API returns the lifecycle rules of a bucket.To obtain ", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Lifecycle Rules,Lifecycle Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Lifecycle Rules", + "githuburl":"" + }, + { + "uri":"obs_21_1104.html", + "node_id":"obs_21_1104.xml", + "product_code":"obs", + "code":"91", + "des":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API deletes the lifecycle configuration of a bucket.To", + "doc_type":"sdk-java-devg", + "kw":"Deleting Lifecycle Rules,Lifecycle Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting Lifecycle Rules", + "githuburl":"" + }, + { + "uri":"obs_21_1400.html", + "node_id":"obs_21_1400.xml", + "product_code":"obs", + "code":"92", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Cross-Origin Resource Sharing", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Cross-Origin Resource Sharing", + "githuburl":"" + }, + { + "uri":"obs_21_1401.html", + "node_id":"obs_21_1401.xml", + "product_code":"obs", + "code":"93", + "des":"Cross-origin access refers to access between different domains. Restricting cross-origin access is a browser policy for security purposes, that is, the same-origin policy", + "doc_type":"sdk-java-devg", + "kw":"Overview,Cross-Origin Resource Sharing,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1402.html", + "node_id":"obs_21_1402.xml", + "product_code":"obs", + "code":"94", + "des":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "doc_type":"sdk-java-devg", + "kw":"Configuring a CORS Rule,Cross-Origin Resource Sharing,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring a CORS Rule", + "githuburl":"" + }, + { + "uri":"obs_21_1403.html", + "node_id":"obs_21_1403.xml", + "product_code":"obs", + "code":"95", + "des":"CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, websit", + "doc_type":"sdk-java-devg", + "kw":"Obtaining a CORS Rule,Cross-Origin Resource Sharing,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining a CORS Rule", + "githuburl":"" + }, + { + "uri":"obs_21_1404.html", + "node_id":"obs_21_1404.xml", + "product_code":"obs", + "code":"96", + "des":"CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, websit", + "doc_type":"sdk-java-devg", + "kw":"Deleting a CORS Rule,Cross-Origin Resource Sharing,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting a CORS Rule", + "githuburl":"" + }, + { + "uri":"obs_21_1500.html", + "node_id":"obs_21_1500.xml", + "product_code":"obs", + "code":"97", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Logging", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Logging", + "githuburl":"" + }, + { + "uri":"obs_21_1501.html", + "node_id":"obs_21_1501.xml", + "product_code":"obs", + "code":"98", + "des":"OBS allows you to configure access logging for buckets. After the configuration, access to buckets will be recorded in logs. These logs will be saved in specific buckets ", + "doc_type":"sdk-java-devg", + "kw":"Overview,Logging,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1502.html", + "node_id":"obs_21_1502.xml", + "product_code":"obs", + "code":"99", + "des":"This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default.", + "doc_type":"sdk-java-devg", + "kw":"Configuring Logging for a Bucket,Logging,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Logging for a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1503.html", + "node_id":"obs_21_1503.xml", + "product_code":"obs", + "code":"100", + "des":"This API returns the logging configuration of a bucket.To obtain the logging configuration of a bucket, you must be the bucket owner or have the required permission (obs:", + "doc_type":"sdk-java-devg", + "kw":"Obtaining the Logging Configuration of a Bucket,Logging,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining the Logging Configuration of a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1600.html", + "node_id":"obs_21_1600.xml", + "product_code":"obs", + "code":"101", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Static Website Hosting", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Static Website Hosting", + "githuburl":"" + }, + { + "uri":"obs_21_1601.html", + "node_id":"obs_21_1601.xml", + "product_code":"obs", + "code":"102", + "des":"To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configur", + "doc_type":"sdk-java-devg", + "kw":"Overview,Static Website Hosting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1602.html", + "node_id":"obs_21_1602.xml", + "product_code":"obs", + "code":"103", + "des":"To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configur", + "doc_type":"sdk-java-devg", + "kw":"Hosting Website Files in a Bucket,Static Website Hosting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Hosting Website Files in a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1603.html", + "node_id":"obs_21_1603.xml", + "product_code":"obs", + "code":"104", + "des":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "doc_type":"sdk-java-devg", + "kw":"Configuring Static Website Hosting,Static Website Hosting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Static Website Hosting", + "githuburl":"" + }, + { + "uri":"obs_21_1604.html", + "node_id":"obs_21_1604.xml", + "product_code":"obs", + "code":"105", + "des":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Static Website Hosting Configurations,Static Website Hosting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Static Website Hosting Configurations", + "githuburl":"" + }, + { + "uri":"obs_21_1605.html", + "node_id":"obs_21_1605.xml", + "product_code":"obs", + "code":"106", + "des":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "doc_type":"sdk-java-devg", + "kw":"Deleting Static Website Hosting Configurations,Static Website Hosting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting Static Website Hosting Configurations", + "githuburl":"" + }, + { + "uri":"obs_21_1700.html", + "node_id":"obs_21_1700.xml", + "product_code":"obs", + "code":"107", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Bucket Tag Management", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Bucket Tag Management", + "githuburl":"" + }, + { + "uri":"obs_21_1701.html", + "node_id":"obs_21_1701.xml", + "product_code":"obs", + "code":"108", + "des":"Tags are used to identify and classify OBS buckets.If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can us", + "doc_type":"sdk-java-devg", + "kw":"Overview,Bucket Tag Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1702.html", + "node_id":"obs_21_1702.xml", + "product_code":"obs", + "code":"109", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-java-devg", + "kw":"Configuring Tags for a Bucket,Bucket Tag Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Configuring Tags for a Bucket", + "githuburl":"" + }, + { + "uri":"obs_21_1703.html", + "node_id":"obs_21_1703.xml", + "product_code":"obs", + "code":"110", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-java-devg", + "kw":"Obtaining Bucket Tags,Bucket Tag Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Obtaining Bucket Tags", + "githuburl":"" + }, + { + "uri":"obs_21_1704.html", + "node_id":"obs_21_1704.xml", + "product_code":"obs", + "code":"111", + "des":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "doc_type":"sdk-java-devg", + "kw":"Deleting Bucket Tags,Bucket Tag Management,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Deleting Bucket Tags", + "githuburl":"" + }, + { + "uri":"obs_21_1900.html", + "node_id":"obs_21_1900.xml", + "product_code":"obs", + "code":"112", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Server-Side Encryption", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Server-Side Encryption", + "githuburl":"" + }, + { + "uri":"obs_21_1901.html", + "node_id":"obs_21_1901.xml", + "product_code":"obs", + "code":"113", + "des":"OBS provides server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.The encryption and dec", + "doc_type":"sdk-java-devg", + "kw":"Overview,Server-Side Encryption,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_1902.html", + "node_id":"obs_21_1902.xml", + "product_code":"obs", + "code":"114", + "des":"The following table lists APIs related to server-side encryption:", + "doc_type":"sdk-java-devg", + "kw":"Server-Side Encryption APIs,Server-Side Encryption,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Server-Side Encryption APIs", + "githuburl":"" + }, + { + "uri":"obs_21_1903.html", + "node_id":"obs_21_1903.xml", + "product_code":"obs", + "code":"115", + "des":"The following code shows an example of encrypting an object with SSE-C before uploading it:The following code shows an example of downloading an object encrypted with SSE", + "doc_type":"sdk-java-devg", + "kw":"Code Examples for Server-Side Encryption,Server-Side Encryption,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Code Examples for Server-Side Encryption", + "githuburl":"" + }, + { + "uri":"obs_21_2301.html", + "node_id":"obs_21_2301.xml", + "product_code":"obs", + "code":"116", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Client-Side Encryption", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Client-Side Encryption", + "githuburl":"" + }, + { + "uri":"obs_21_2302.html", + "node_id":"obs_21_2302.xml", + "product_code":"obs", + "code":"117", + "des":"Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS serve", + "doc_type":"sdk-java-devg", + "kw":"Overview,Client-Side Encryption,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Overview", + "githuburl":"" + }, + { + "uri":"obs_21_2303.html", + "node_id":"obs_21_2303.xml", + "product_code":"obs", + "code":"118", + "des":"OBS SDK for Java provides two cipher suites for you to choose from.CtrRSACipherGenerator is inherited from CTRCipherGenerator but only requires you to provide an RSA publ", + "doc_type":"sdk-java-devg", + "kw":"Client-Side Encryption APIs,Client-Side Encryption,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Client-Side Encryption APIs", + "githuburl":"" + }, + { + "uri":"obs_21_0300.html", + "node_id":"obs_21_0300.xml", + "product_code":"obs", + "code":"119", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Fault Locating", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Fault Locating", + "githuburl":"" + }, + { + "uri":"obs_21_0301.html", + "node_id":"obs_21_0301.xml", + "product_code":"obs", + "code":"120", + "des":"If problems occur when using the OBS Java SDK, you can perform the following steps to analyze and locate the problems.You can click here to view the details about ObsExce", + "doc_type":"sdk-java-devg", + "kw":"Methods,Fault Locating,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Methods", + "githuburl":"" + }, + { + "uri":"obs_21_0303.html", + "node_id":"obs_21_0303.xml", + "product_code":"obs", + "code":"121", + "des":"Dependency missing and dependency conflict are commonly encountered in Java development or during SDK integration. If error message \"ClassNotFoundException\" or \"NoClassDe", + "doc_type":"sdk-java-devg", + "kw":"Resolving Dependency Missing or Conflicts,Fault Locating,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Resolving Dependency Missing or Conflicts", + "githuburl":"" + }, + { + "uri":"obs_21_0302.html", + "node_id":"obs_21_0302.xml", + "product_code":"obs", + "code":"122", + "des":"Possible causes are as follows:The SK input into ObsClient initialization is incorrect. Solution: Make sure that the SK is correct.This problem is caused by a bug in the ", + "doc_type":"sdk-java-devg", + "kw":"Other Notable Issues,Fault Locating,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Other Notable Issues", + "githuburl":"" + }, + { + "uri":"obs_21_2000.html", + "node_id":"obs_21_2000.xml", + "product_code":"obs", + "code":"123", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Troubleshooting", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Troubleshooting", + "githuburl":"" + }, + { + "uri":"obs_21_2001.html", + "node_id":"obs_21_2001.xml", + "product_code":"obs", + "code":"124", + "des":"The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HT", + "doc_type":"sdk-java-devg", + "kw":"HTTP Status Codes,Troubleshooting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"HTTP Status Codes", + "githuburl":"" + }, + { + "uri":"obs_21_2002.html", + "node_id":"obs_21_2002.xml", + "product_code":"obs", + "code":"125", + "des":"If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned. The following table lists details", + "doc_type":"sdk-java-devg", + "kw":"OBS Server-side Error Codes,Troubleshooting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"OBS Server-side Error Codes", + "githuburl":"" + }, + { + "uri":"obs_21_2005.html", + "node_id":"obs_21_2005.xml", + "product_code":"obs", + "code":"126", + "des":"SDK custom exceptions (ObsException), thrown by ObsClient, are inherited from class java.lang.RuntimeException. Exceptions are usually OBS server errors, including OBS er", + "doc_type":"sdk-java-devg", + "kw":"SDK Exceptions,Troubleshooting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"SDK Exceptions", + "githuburl":"" + }, + { + "uri":"obs_21_2003.html", + "node_id":"obs_21_2003.xml", + "product_code":"obs", + "code":"127", + "des":"After you successfully call an API in an instance of ObsClient, an instance of the HeaderResponse class (or of its sub-class) will be returned.It contains information abo", + "doc_type":"sdk-java-devg", + "kw":"SDK Common Response Headers,Troubleshooting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"SDK Common Response Headers", + "githuburl":"" + }, + { + "uri":"obs_21_2004.html", + "node_id":"obs_21_2004.xml", + "product_code":"obs", + "code":"128", + "des":"Save the log4j2.xml file obtained from the OBS Java SDK package to the classpath root directory.Call Log4j2Configurator.setLogConfig to specify the save path of log4j2.xm", + "doc_type":"sdk-java-devg", + "kw":"Log Analysis,Troubleshooting,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Log Analysis", + "githuburl":"" + }, + { + "uri":"obs_21_2100.html", + "node_id":"obs_21_2100.xml", + "product_code":"obs", + "code":"129", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"FAQs", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"FAQs", + "githuburl":"" + }, + { + "uri":"obs_21_2107.html", + "node_id":"obs_21_2107.xml", + "product_code":"obs", + "code":"130", + "des":"To do this, perform the following steps:", + "doc_type":"sdk-java-devg", + "kw":"How Can I Set an Object to Be Accessible to Anonymous Users?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Can I Set an Object to Be Accessible to Anonymous Users?", + "githuburl":"" + }, + { + "uri":"obs_21_2109.html", + "node_id":"obs_21_2109.xml", + "product_code":"obs", + "code":"131", + "des":"SDK uses the maxErrorRetry parameter configured in Creating and Configuring an OBS Client to retry. The default value for retry times is 3. 0 to 5 is recommended.If the n", + "doc_type":"sdk-java-devg", + "kw":"What Is the Retry Mechanism of SDK?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"What Is the Retry Mechanism of SDK?", + "githuburl":"" + }, + { + "uri":"obs_21_2110.html", + "node_id":"obs_21_2110.xml", + "product_code":"obs", + "code":"132", + "des":"After a bucket is configured to work in static website hosting mode, you can use the following method to combine the static website access address of the bucket.https://b", + "doc_type":"sdk-java-devg", + "kw":"How Do I Obtain the Static Website Access Address of a Bucket?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Obtain the Static Website Access Address of a Bucket?", + "githuburl":"" + }, + { + "uri":"obs_21_2111.html", + "node_id":"obs_21_2111.xml", + "product_code":"obs", + "code":"133", + "des":"If the uploaded object is set to be read by anonymous users, anonymous users can download the object through the object URL directly. Methods to obtain the object URL are", + "doc_type":"sdk-java-devg", + "kw":"How Do I Obtain an Object URL?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Obtain an Object URL?", + "githuburl":"" + }, + { + "uri":"obs_21_2112.html", + "node_id":"obs_21_2112.xml", + "product_code":"obs", + "code":"134", + "des":"If a file exceeds 100 MB, you are advised to upload the file using multipart upload.Multipart upload refers to splitting an object into multiple parts and uploading them ", + "doc_type":"sdk-java-devg", + "kw":"How to Improve the Speed of Uploading Large Files over the Public Network?,FAQs,Developer Guide (Jav", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How to Improve the Speed of Uploading Large Files over the Public Network?", + "githuburl":"" + }, + { + "uri":"obs_21_2114.html", + "node_id":"obs_21_2114.xml", + "product_code":"obs", + "code":"135", + "des":"In a multipart upload, you can specify a part of the file to be uploaded by performing the following steps:For details, see Multipart Upload.", + "doc_type":"sdk-java-devg", + "kw":"How Can I Perform a Multipart Upload?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Can I Perform a Multipart Upload?", + "githuburl":"" + }, + { + "uri":"obs_21_2115.html", + "node_id":"obs_21_2115.xml", + "product_code":"obs", + "code":"136", + "des":"In a multipart download, you can specify the range of data to be downloaded. The procedure is as follows:For details, see Downloading an Object - Range-Based.", + "doc_type":"sdk-java-devg", + "kw":"How Can I Perform a Download in Multipart Mode?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Can I Perform a Download in Multipart Mode?", + "githuburl":"" + }, + { + "uri":"obs_21_2117.html", + "node_id":"obs_21_2117.xml", + "product_code":"obs", + "code":"137", + "des":"After the upload is complete, you can call ObsClient.getObjectMetadata to obtain the size and last modification time of the newly uploaded object and compare them with th", + "doc_type":"sdk-java-devg", + "kw":"How Do I Confirm that an Upload is Successful If I Upload an Object to Overwrite an Existing Object ", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Confirm that an Upload is Successful If I Upload an Object to Overwrite an Existing Object with the Same Name in a Bucket?", + "githuburl":"" + }, + { + "uri":"obs_21_2118.html", + "node_id":"obs_21_2118.xml", + "product_code":"obs", + "code":"138", + "des":"If the object is encrypted with SSE-KMS, the server automatically decrypts the object when you use the URL of the object to download it.If the object is encrypted with SS", + "doc_type":"sdk-java-devg", + "kw":"How Do I Download an Encrypted Object Using a URL?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Download an Encrypted Object Using a URL?", + "githuburl":"" + }, + { + "uri":"obs_21_2119.html", + "node_id":"obs_21_2119.xml", + "product_code":"obs", + "code":"139", + "des":"Sample code of generating an SSE-C encryption key and its MD5 value:", + "doc_type":"sdk-java-devg", + "kw":"How Do I Generate an SSE-C Encryption Key?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Generate an SSE-C Encryption Key?", + "githuburl":"" + }, + { + "uri":"obs_21_2121.html", + "node_id":"obs_21_2121.xml", + "product_code":"obs", + "code":"140", + "des":"No.Currently, the SDK does not provide such APIs. You need to encapsulate the service codes for uploading, downloading, or copying objects in a batch by yourself. The pro", + "doc_type":"sdk-java-devg", + "kw":"Does the SDK Support Uploading, Downloading, or Copying Objects in a Batch?,FAQs,Developer Guide (Ja", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Does the SDK Support Uploading, Downloading, or Copying Objects in a Batch?", + "githuburl":"" + }, + { + "uri":"obs_21_2124.html", + "node_id":"obs_21_2124.xml", + "product_code":"obs", + "code":"141", + "des":"Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.If you do not specify Co", + "doc_type":"sdk-java-devg", + "kw":"What Is Content-Type (MIME)?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"What Is Content-Type (MIME)?", + "githuburl":"" + }, + { + "uri":"obs_23_1712.html", + "node_id":"obs_23_1712.xml", + "product_code":"obs", + "code":"142", + "des":"When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain", + "doc_type":"sdk-java-devg", + "kw":"How Do I Get My Account ID and User ID?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Get My Account ID and User ID?", + "githuburl":"" + }, + { + "uri":"obs_23_1713.html", + "node_id":"obs_23_1713.xml", + "product_code":"obs", + "code":"143", + "des":"This example limits the upload rate by specifying thex-obs-traffic-limitheader. The SDK transparently transmits the header for the server to verify.", + "doc_type":"sdk-java-devg", + "kw":"How Do I Limit the Rate During Object Upload?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Limit the Rate During Object Upload?", + "githuburl":"" + }, + { + "uri":"obs_23_1714.html", + "node_id":"obs_23_1714.xml", + "product_code":"obs", + "code":"144", + "des":"This example limits the download rate by specifying thex-obs-traffic-limitheader. The SDK transparently transmits the header for the server to verify.", + "doc_type":"sdk-java-devg", + "kw":"How Do I Limit the Rate During Object Download?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"How Do I Limit the Rate During Object Download?", + "githuburl":"" + }, + { + "uri":"obs_23_1715.html", + "node_id":"obs_23_1715.xml", + "product_code":"", + "code":"145", + "des":"This example uploads localfile to examplebucket as objectkey and sets the referer header to https://example.com*.", + "doc_type":"", + "kw":"How Do I Configure the referer Header?,FAQs,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + + } + ], + "title":"How Do I Configure the referer Header?", + "githuburl":"" + }, + { + "uri":"obs_21_2202.html", + "node_id":"obs_21_2202.xml", + "product_code":"obs", + "code":"146", + "des":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "doc_type":"sdk-java-devg", + "kw":"Change History,Developer Guide (Java SDK)", + "search_title":"", + "metedata":[ + { + "opensource":"false;true", + "prodname":"obs", + "documenttype":"sdk-java-devg" + } + ], + "title":"Change History", + "githuburl":"" + } +] \ No newline at end of file diff --git a/docs/obs_3rd_party/java_sdk/CLASS.TXT.json b/docs/obs_3rd_party/java_sdk/CLASS.TXT.json new file mode 100644 index 000000000..92d3bcf6b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/CLASS.TXT.json @@ -0,0 +1,1316 @@ +[ + { + "desc":"This section describes version compatibility and important notes about Object Storage Service (OBS) SDK for Java.Recommended JDK versions: JDK 8 or laterThird-party depen", + "product_code":"obs", + "title":"Before You Start", + "uri":"obs_21_0101.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"1" + }, + { + "desc":"Table 1 lists the bucket-related APIs.Table 2lists object-related APIs.Table 3 lists the APIs related to temporarily authorized access.Table 4 lists the APIs related to v", + "product_code":"obs", + "title":"API Overview", + "uri":"obs_21_0002.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"2" + }, + { + "desc":"Before using OBS SDK for Java to access OBS, you need to prepare the service and development environments. To prepare the service environment, you will need an account an", + "product_code":"obs", + "title":"Preparations", + "uri":"obs_21_0102.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"3" + }, + { + "desc":"Latest version of OBS Java SDK: DownloadYou can download the source code of SDK for Java and compile the source code to create a JAR package. Before using this method, en", + "product_code":"obs", + "title":"SDK Download and Installation", + "uri":"obs_21_0001.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"4" + }, + { + "desc":"This section introduces how to use OBS SDK for Java to perform some basic actions, such as creating a bucket, and uploading, downloading, listing, and deleting objects.En", + "product_code":"obs", + "title":"Getting Started", + "uri":"obs_21_0100.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"5" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Initialization", + "uri":"obs_21_0200.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"6" + }, + { + "desc":"After the SDK is installed, you need to create and configure an OBS client and configure the logging for the SDK to complete the initialization.", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_0201.html", + "doc_type":"sdk-java-devg", + "p_code":"6", + "code":"7" + }, + { + "desc":"This section describes how to create and configure an OBS client. If you already have a client, skip this section and obtain the API details by referring to API Overview.", + "product_code":"obs", + "title":"Creating and Configuring an OBS Client", + "uri":"obs_21_0202.html", + "doc_type":"sdk-java-devg", + "p_code":"6", + "code":"8" + }, + { + "desc":"OBS SDK for Java offers logging based on the open-source Apache Log4j 2 library. By default, the SDK stores WARN log files to the directory specified by the JDK system va", + "product_code":"obs", + "title":"Configuring SDK Logging", + "uri":"obs_21_0204.html", + "doc_type":"sdk-java-devg", + "p_code":"6", + "code":"9" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Bucket Management", + "uri":"obs_21_0400.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"10" + }, + { + "desc":"This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.When creating a bucket, you can also configure parameters such a", + "product_code":"obs", + "title":"Creating a Bucket", + "uri":"obs_21_0401.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"11" + }, + { + "desc":"OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current ", + "product_code":"obs", + "title":"Obtaining a Bucket List", + "uri":"obs_21_0402.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"12" + }, + { + "desc":"This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 min", + "product_code":"obs", + "title":"Deleting a Bucket", + "uri":"obs_21_0403.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"13" + }, + { + "desc":"This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.To check whether a bucke", + "product_code":"obs", + "title":"Checking Whether a Bucket Exists", + "uri":"obs_21_0404.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"14" + }, + { + "desc":"This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.To obtain bucket metadata, you must be the bucket owne", + "product_code":"obs", + "title":"Obtaining Bucket Metadata", + "uri":"obs_21_0405.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"15" + }, + { + "desc":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "product_code":"obs", + "title":"Setting a Bucket ACL", + "uri":"obs_21_0406.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"16" + }, + { + "desc":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "product_code":"obs", + "title":"Obtaining a Bucket ACL", + "uri":"obs_21_0412.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"17" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Configuring a Bucket Policy", + "uri":"obs_21_0407.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"18" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Obtaining the Policy of a Bucket", + "uri":"obs_21_0413.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"19" + }, + { + "desc":"OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control ca", + "product_code":"obs", + "title":"Deleting a Bucket Policy", + "uri":"obs_21_0414.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"20" + }, + { + "desc":"This API returns the region where a bucket is located.To obtain the region of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucket", + "product_code":"obs", + "title":"Obtaining the Region of a Bucket", + "uri":"obs_21_0408.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"21" + }, + { + "desc":"This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.OBS measures bucket storage stat", + "product_code":"obs", + "title":"Obtaining Storage Information of a Bucket", + "uri":"obs_21_0409.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"22" + }, + { + "desc":"A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number", + "product_code":"obs", + "title":"Configuring a Storage Quota", + "uri":"obs_21_0410.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"23" + }, + { + "desc":"This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.A bucket quota mus", + "product_code":"obs", + "title":"Obtaining a Bucket Storage Quota", + "uri":"obs_21_0415.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"24" + }, + { + "desc":"This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object ", + "product_code":"obs", + "title":"Configuring a Storage Class for a Bucket", + "uri":"obs_21_0411.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"25" + }, + { + "desc":"This API returns the storage class of a bucket.To obtain a bucket's storage class, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStora", + "product_code":"obs", + "title":"Obtaining the Storage Class of a Bucket", + "uri":"obs_21_0416.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"26" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Bucket Inventory", + "uri":"obs_21_0421.html", + "doc_type":"sdk-java-devg", + "p_code":"10", + "code":"27" + }, + { + "desc":"This API configures an inventory rule for the bucket. With this API, object information in a bucket (source) is regularly listed and saved as CSV files. These files are t", + "product_code":"obs", + "title":"Configuring an Inventory Rule", + "uri":"obs_21_0417.html", + "doc_type":"sdk-java-devg", + "p_code":"27", + "code":"28" + }, + { + "desc":"This API returns an inventory rule (identified by configurationId) for the bucket.To obtain a bucket inventory rule, you must be the bucket owner or have the required per", + "product_code":"obs", + "title":"Obtaining an Inventory Rule", + "uri":"obs_21_0418.html", + "doc_type":"sdk-java-devg", + "p_code":"27", + "code":"29" + }, + { + "desc":"This API returns a list of all inventory rules for the bucket.To list inventory rules for a bucket, you must be the bucket owner or have the required permission (obs:buck", + "product_code":"obs", + "title":"Listing Inventory Rules", + "uri":"obs_21_0419.html", + "doc_type":"sdk-java-devg", + "p_code":"27", + "code":"30" + }, + { + "desc":"This API deletes an inventory rule (identified by configurationId) from the bucket.To delete a bucket inventory rule, you must be the bucket owner or have the required pe", + "product_code":"obs", + "title":"Deleting an Inventory Rule", + "uri":"obs_21_0420.html", + "doc_type":"sdk-java-devg", + "p_code":"27", + "code":"31" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Object Upload", + "uri":"obs_21_0600.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"32" + }, + { + "desc":"In OBS, objects are basic data units that users can perform operations on. OBS Java SDK provides abundant APIs for object upload in the following methods:StreamingFile-ba", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_0601.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"33" + }, + { + "desc":"This API uploads a local fileto OBS over the Internet. These files can be texts, images, videos, or any other type of files.You can upload texts, images, videos, or any o", + "product_code":"obs", + "title":"Uploading an Object - Streaming", + "uri":"obs_21_0602.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"34" + }, + { + "desc":"This API uploads local filesto OBS over the Internet. The file to be uploaded can be of any type.To upload an object, you must be the bucket owner or have the required pe", + "product_code":"obs", + "title":"Uploading an Object - File-Based", + "uri":"obs_21_0603.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"35" + }, + { + "desc":"This API returns the upload progress of a specified object.You can call PutObjectRequest.setProgressListener to obtain the upload progress.To obtain the upload progress, ", + "product_code":"obs", + "title":"Obtaining the Upload Progress", + "uri":"obs_21_0604.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"36" + }, + { + "desc":"This API creates a folder in an existing bucket to manage data in OBS.OBS does not involve folders like in a file system. All elements in buckets are objects. To create a", + "product_code":"obs", + "title":"Creating a Folder", + "uri":"obs_21_0605.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"37" + }, + { + "desc":"This API configures metadata for an object when uploading it. Object metadata include the object length, MIME type, MD5 value (for verification), storage class, and custo", + "product_code":"obs", + "title":"Configuring Object Metadata", + "uri":"obs_21_0606.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"38" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Multipart Upload", + "uri":"obs_21_0607.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"39" + }, + { + "desc":"You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:Files to be uploaded are larger than 100 MB.The network con", + "product_code":"obs", + "title":"Multipart Upload Overview", + "uri":"obs_21_0614.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"40" + }, + { + "desc":"This API initiates a multipart upload and returns a globally unique upload ID. You can use this upload ID in your subsequent requests including abortMultipartUpload, list", + "product_code":"obs", + "title":"Initiating a Multipart Upload", + "uri":"obs_21_0615.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"41" + }, + { + "desc":"After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part", + "product_code":"obs", + "title":"Uploading a Part", + "uri":"obs_21_0616.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"42" + }, + { + "desc":"This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, yo", + "product_code":"obs", + "title":"Assembling Parts", + "uri":"obs_21_0617.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"43" + }, + { + "desc":"Multipart upload is mainly used for large file upload or when the network connection is poor.You can use UploadPartRequest.setOffset and UploadPartRequest.setPartSize to ", + "product_code":"obs", + "title":"Code Example of a Multipart Upload", + "uri":"obs_21_0618.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"44" + }, + { + "desc":"This API aborts a multipart upload using the multipart upload ID.After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupie", + "product_code":"obs", + "title":"Aborting a Multipart Upload", + "uri":"obs_21_0619.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"45" + }, + { + "desc":"This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.You can list the uploaded parts of a specified multipart upload", + "product_code":"obs", + "title":"Listing Uploaded Parts", + "uri":"obs_21_0620.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"46" + }, + { + "desc":"This API lists ongoing multipart uploads.Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of", + "product_code":"obs", + "title":"Listing Multipart Uploads", + "uri":"obs_21_0621.html", + "doc_type":"sdk-java-devg", + "p_code":"39", + "code":"47" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes. The object expiration time set using this API takes preced", + "product_code":"obs", + "title":"Configuring Lifecycle Rules", + "uri":"obs_21_0608.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"48" + }, + { + "desc":"This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.The appendObject operation adds data to ", + "product_code":"obs", + "title":"Uploading an Object - Append", + "uri":"obs_21_0609.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"49" + }, + { + "desc":"The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connec", + "product_code":"obs", + "title":"Uploading an Object - Resumable", + "uri":"obs_21_0611.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"50" + }, + { + "desc":"This API uploads an object up to 5 GB to a specified bucket in HTML form.You can call ObsClient.createPostSignature to generate request parameters for a browser-based upl", + "product_code":"obs", + "title":"Uploading an Object - Browser-Based", + "uri":"obs_21_0612.html", + "doc_type":"sdk-java-devg", + "p_code":"32", + "code":"51" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Object Download", + "uri":"obs_21_0700.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"52" + }, + { + "desc":"OBS Java SDK provides abundant APIs for object download in the following methods:Streaming DownloadPartial DownloadResumable download", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_0701.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"53" + }, + { + "desc":"When you call ObsClient.getObject, an instance of ObsObject will be returned. This instance contains the contents of the object such as its name, attributes, input stream", + "product_code":"obs", + "title":"Downloading an Object - Streaming", + "uri":"obs_21_0702.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"54" + }, + { + "desc":"This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are r", + "product_code":"obs", + "title":"Downloading an Object - Range-Based", + "uri":"obs_21_0703.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"55" + }, + { + "desc":"This API returns the download progress of a specified object.You can call GetObjectRequest.setProgressInterval to obtain the download progress.To obtain the download prog", + "product_code":"obs", + "title":"Obtaining the Download Progress", + "uri":"obs_21_0704.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"56" + }, + { + "desc":"This API returns the objects that meet one or more conditions. If there are no objects that meet the specified conditions, an error is returned.To download an object, you", + "product_code":"obs", + "title":"Downloading an Object - Conditional", + "uri":"obs_21_0705.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"57" + }, + { + "desc":"This API rewrites the following HTTP/HTTPS response headers when downloading an object: Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition, and C", + "product_code":"obs", + "title":"Rewriting Response Headers", + "uri":"obs_21_0706.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"58" + }, + { + "desc":"Object metadata is a set of key-value pairs that describe the object and is used for object management.This API returns the user-defined object metadata after the object ", + "product_code":"obs", + "title":"Obtaining User-defined Metadata", + "uri":"obs_21_0707.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"59" + }, + { + "desc":"Cold objects must first be restored before you can download them. Cold objects can be restored in either of the following ways.To restore a Cold object, you must be the b", + "product_code":"obs", + "title":"Restoring a Cold Object", + "uri":"obs_21_0708.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"60" + }, + { + "desc":"Downloading large files often fails due to an unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download ", + "product_code":"obs", + "title":"Downloading an Object - Resumable", + "uri":"obs_21_0709.html", + "doc_type":"sdk-java-devg", + "p_code":"52", + "code":"61" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Object Management", + "uri":"obs_21_0800.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"62" + }, + { + "desc":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Currently, only the system-defined metadata is supported.There are", + "product_code":"obs", + "title":"Configuring Object Metadata", + "uri":"obs_21_0806.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"63" + }, + { + "desc":"Object metadata is a set of name-value pairs that describe the object and is used for object management.Users with the READ permission on objects can send HEAD requests t", + "product_code":"obs", + "title":"Obtaining Object Metadata", + "uri":"obs_21_0801.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"64" + }, + { + "desc":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "product_code":"obs", + "title":"Configuring an Object ACL", + "uri":"obs_21_0802.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"65" + }, + { + "desc":"Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over r", + "product_code":"obs", + "title":"Obtaining an Object ACL", + "uri":"obs_21_0808.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"66" + }, + { + "desc":"This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet", + "product_code":"obs", + "title":"Listing Objects", + "uri":"obs_21_0803.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"67" + }, + { + "desc":"This API deletes objects from a specific bucket.To delete an object, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or Delet", + "product_code":"obs", + "title":"Deleting an Object", + "uri":"obs_21_0804.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"68" + }, + { + "desc":"This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.In a batch delete operation, OBS concurrently deletes the specified object", + "product_code":"obs", + "title":"Batch Deleting Objects", + "uri":"obs_21_0809.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"69" + }, + { + "desc":"This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.To co", + "product_code":"obs", + "title":"Copying an Object", + "uri":"obs_21_0805.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"70" + }, + { + "desc":"This API allows you to upload a part by copying an object or part of this object.You can call ObsClient.copyPart to copy parts.To copy an object, you must be the bucket o", + "product_code":"obs", + "title":"Copying an Object - Multipart", + "uri":"obs_21_0810.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"71" + }, + { + "desc":"This API checks whether an object exists. If the returned HTTP status code is 200, the object exists. If the returned HTTP status code is 404, the object or bucket does n", + "product_code":"obs", + "title":"Checking Whether an Object Exists", + "uri":"obs_21_0807.html", + "doc_type":"sdk-java-devg", + "p_code":"62", + "code":"72" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Temporarily Authorized Access", + "uri":"obs_21_0900.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"73" + }, + { + "desc":"ObsClient allows you to create a URL with Query parameters that carry authentication information by specifying the AK and SK, HTTP method, and request parameters. You can", + "product_code":"obs", + "title":"Accessing OBS Using a Signed URL", + "uri":"obs_21_0901.html", + "doc_type":"sdk-java-devg", + "p_code":"73", + "code":"74" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Versioning", + "uri":"obs_21_1000.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"75" + }, + { + "desc":"You can use versioning to store multiple versions of an object in a bucket.When versioning is enabled for a bucket, OBS keeps multiple versions of an object in the bucket", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1001.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"76" + }, + { + "desc":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "product_code":"obs", + "title":"Configuring Versioning for a Bucket", + "uri":"obs_21_1002.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"77" + }, + { + "desc":"You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover yo", + "product_code":"obs", + "title":"Obtaining the Versioning Status of a Bucket", + "uri":"obs_21_1003.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"78" + }, + { + "desc":"You can call ObsClient.getObject to obtain an object version by specifying the version ID (versionId).To download an object, you must be the bucket owner or have the requ", + "product_code":"obs", + "title":"Obtaining an Object Version", + "uri":"obs_21_1004.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"79" + }, + { + "desc":"This API copies an object version in a specified bucket.You can call ObsClient.copyObject to copy an object version by specifying the version ID (versionId).To copy an ob", + "product_code":"obs", + "title":"Copying an Object Version", + "uri":"obs_21_1005.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"80" + }, + { + "desc":"This API downloads a Cold object. To download such an object, you must restore it first. For the options for the restore speed, see Table 3.You can call ObsClient.restore", + "product_code":"obs", + "title":"Restoring a Specific Cold Object Version", + "uri":"obs_21_1006.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"81" + }, + { + "desc":"This API lists some or all of the object versions in a bucket. When listing the object versions, you can specify the criteria such as the prefix, number, and start positi", + "product_code":"obs", + "title":"Listing Object Versions", + "uri":"obs_21_1007.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"82" + }, + { + "desc":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can set access control p", + "product_code":"obs", + "title":"Setting an ACL for an Object Version", + "uri":"obs_21_1008.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"83" + }, + { + "desc":"OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can call an ACL API to m", + "product_code":"obs", + "title":"Obtaining the ACL of an Object Version", + "uri":"obs_21_1010.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"84" + }, + { + "desc":"This API deletes an object from a specific bucket.You can call ObsClient.deleteObject to pass a version ID (versionId) to delete an object version.To delete an object, yo", + "product_code":"obs", + "title":"Deleting an Object Version", + "uri":"obs_21_1009.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"85" + }, + { + "desc":"This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.In a batch delete operation, OBS concurrently deletes the specified object", + "product_code":"obs", + "title":"Batch Deleting Object Versions", + "uri":"obs_21_1011.html", + "doc_type":"sdk-java-devg", + "p_code":"75", + "code":"86" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Lifecycle Management", + "uri":"obs_21_1100.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"87" + }, + { + "desc":"OBS allows you to set lifecycle rules for buckets to automatically transition the storage class of an object or delete expired objects, to effectively use storage feature", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1101.html", + "doc_type":"sdk-java-devg", + "p_code":"87", + "code":"88" + }, + { + "desc":"This API configures lifecycle rules for a bucket to periodically delete objects in the bucket or transition objects between storage classes.An object will be automaticall", + "product_code":"obs", + "title":"Setting Lifecycle Rules", + "uri":"obs_21_1102.html", + "doc_type":"sdk-java-devg", + "p_code":"87", + "code":"89" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API returns the lifecycle rules of a bucket.To obtain ", + "product_code":"obs", + "title":"Obtaining Lifecycle Rules", + "uri":"obs_21_1103.html", + "doc_type":"sdk-java-devg", + "p_code":"87", + "code":"90" + }, + { + "desc":"You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.This API deletes the lifecycle configuration of a bucket.To", + "product_code":"obs", + "title":"Deleting Lifecycle Rules", + "uri":"obs_21_1104.html", + "doc_type":"sdk-java-devg", + "p_code":"87", + "code":"91" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Cross-Origin Resource Sharing", + "uri":"obs_21_1400.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"92" + }, + { + "desc":"Cross-origin access refers to access between different domains. Restricting cross-origin access is a browser policy for security purposes, that is, the same-origin policy", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1401.html", + "doc_type":"sdk-java-devg", + "p_code":"92", + "code":"93" + }, + { + "desc":"Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources", + "product_code":"obs", + "title":"Configuring a CORS Rule", + "uri":"obs_21_1402.html", + "doc_type":"sdk-java-devg", + "p_code":"92", + "code":"94" + }, + { + "desc":"CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, websit", + "product_code":"obs", + "title":"Obtaining a CORS Rule", + "uri":"obs_21_1403.html", + "doc_type":"sdk-java-devg", + "p_code":"92", + "code":"95" + }, + { + "desc":"CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, websit", + "product_code":"obs", + "title":"Deleting a CORS Rule", + "uri":"obs_21_1404.html", + "doc_type":"sdk-java-devg", + "p_code":"92", + "code":"96" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Logging", + "uri":"obs_21_1500.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"97" + }, + { + "desc":"OBS allows you to configure access logging for buckets. After the configuration, access to buckets will be recorded in logs. These logs will be saved in specific buckets ", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1501.html", + "doc_type":"sdk-java-devg", + "p_code":"97", + "code":"98" + }, + { + "desc":"This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default.", + "product_code":"obs", + "title":"Configuring Logging for a Bucket", + "uri":"obs_21_1502.html", + "doc_type":"sdk-java-devg", + "p_code":"97", + "code":"99" + }, + { + "desc":"This API returns the logging configuration of a bucket.To obtain the logging configuration of a bucket, you must be the bucket owner or have the required permission (obs:", + "product_code":"obs", + "title":"Obtaining the Logging Configuration of a Bucket", + "uri":"obs_21_1503.html", + "doc_type":"sdk-java-devg", + "p_code":"97", + "code":"100" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Static Website Hosting", + "uri":"obs_21_1600.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"101" + }, + { + "desc":"To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configur", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1601.html", + "doc_type":"sdk-java-devg", + "p_code":"101", + "code":"102" + }, + { + "desc":"To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configur", + "product_code":"obs", + "title":"Hosting Website Files in a Bucket", + "uri":"obs_21_1602.html", + "doc_type":"sdk-java-devg", + "p_code":"101", + "code":"103" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "product_code":"obs", + "title":"Configuring Static Website Hosting", + "uri":"obs_21_1603.html", + "doc_type":"sdk-java-devg", + "p_code":"101", + "code":"104" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "product_code":"obs", + "title":"Obtaining Static Website Hosting Configurations", + "uri":"obs_21_1604.html", + "doc_type":"sdk-java-devg", + "p_code":"101", + "code":"105" + }, + { + "desc":"You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using", + "product_code":"obs", + "title":"Deleting Static Website Hosting Configurations", + "uri":"obs_21_1605.html", + "doc_type":"sdk-java-devg", + "p_code":"101", + "code":"106" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Bucket Tag Management", + "uri":"obs_21_1700.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"107" + }, + { + "desc":"Tags are used to identify and classify OBS buckets.If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can us", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1701.html", + "doc_type":"sdk-java-devg", + "p_code":"107", + "code":"108" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Configuring Tags for a Bucket", + "uri":"obs_21_1702.html", + "doc_type":"sdk-java-devg", + "p_code":"107", + "code":"109" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Obtaining Bucket Tags", + "uri":"obs_21_1703.html", + "doc_type":"sdk-java-devg", + "p_code":"107", + "code":"110" + }, + { + "desc":"If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analy", + "product_code":"obs", + "title":"Deleting Bucket Tags", + "uri":"obs_21_1704.html", + "doc_type":"sdk-java-devg", + "p_code":"107", + "code":"111" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Server-Side Encryption", + "uri":"obs_21_1900.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"112" + }, + { + "desc":"OBS provides server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.The encryption and dec", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_1901.html", + "doc_type":"sdk-java-devg", + "p_code":"112", + "code":"113" + }, + { + "desc":"The following table lists APIs related to server-side encryption:", + "product_code":"obs", + "title":"Server-Side Encryption APIs", + "uri":"obs_21_1902.html", + "doc_type":"sdk-java-devg", + "p_code":"112", + "code":"114" + }, + { + "desc":"The following code shows an example of encrypting an object with SSE-C before uploading it:The following code shows an example of downloading an object encrypted with SSE", + "product_code":"obs", + "title":"Code Examples for Server-Side Encryption", + "uri":"obs_21_1903.html", + "doc_type":"sdk-java-devg", + "p_code":"112", + "code":"115" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Client-Side Encryption", + "uri":"obs_21_2301.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"116" + }, + { + "desc":"Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS serve", + "product_code":"obs", + "title":"Overview", + "uri":"obs_21_2302.html", + "doc_type":"sdk-java-devg", + "p_code":"116", + "code":"117" + }, + { + "desc":"OBS SDK for Java provides two cipher suites for you to choose from.CtrRSACipherGenerator is inherited from CTRCipherGenerator but only requires you to provide an RSA publ", + "product_code":"obs", + "title":"Client-Side Encryption APIs", + "uri":"obs_21_2303.html", + "doc_type":"sdk-java-devg", + "p_code":"116", + "code":"118" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Fault Locating", + "uri":"obs_21_0300.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"119" + }, + { + "desc":"If problems occur when using the OBS Java SDK, you can perform the following steps to analyze and locate the problems.You can click here to view the details about ObsExce", + "product_code":"obs", + "title":"Methods", + "uri":"obs_21_0301.html", + "doc_type":"sdk-java-devg", + "p_code":"119", + "code":"120" + }, + { + "desc":"Dependency missing and dependency conflict are commonly encountered in Java development or during SDK integration. If error message \"ClassNotFoundException\" or \"NoClassDe", + "product_code":"obs", + "title":"Resolving Dependency Missing or Conflicts", + "uri":"obs_21_0303.html", + "doc_type":"sdk-java-devg", + "p_code":"119", + "code":"121" + }, + { + "desc":"Possible causes are as follows:The SK input into ObsClient initialization is incorrect. Solution: Make sure that the SK is correct.This problem is caused by a bug in the ", + "product_code":"obs", + "title":"Other Notable Issues", + "uri":"obs_21_0302.html", + "doc_type":"sdk-java-devg", + "p_code":"119", + "code":"122" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Troubleshooting", + "uri":"obs_21_2000.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"123" + }, + { + "desc":"The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HT", + "product_code":"obs", + "title":"HTTP Status Codes", + "uri":"obs_21_2001.html", + "doc_type":"sdk-java-devg", + "p_code":"123", + "code":"124" + }, + { + "desc":"If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned. The following table lists details", + "product_code":"obs", + "title":"OBS Server-side Error Codes", + "uri":"obs_21_2002.html", + "doc_type":"sdk-java-devg", + "p_code":"123", + "code":"125" + }, + { + "desc":"SDK custom exceptions (ObsException), thrown by ObsClient, are inherited from class java.lang.RuntimeException. Exceptions are usually OBS server errors, including OBS er", + "product_code":"obs", + "title":"SDK Exceptions", + "uri":"obs_21_2005.html", + "doc_type":"sdk-java-devg", + "p_code":"123", + "code":"126" + }, + { + "desc":"After you successfully call an API in an instance of ObsClient, an instance of the HeaderResponse class (or of its sub-class) will be returned.It contains information abo", + "product_code":"obs", + "title":"SDK Common Response Headers", + "uri":"obs_21_2003.html", + "doc_type":"sdk-java-devg", + "p_code":"123", + "code":"127" + }, + { + "desc":"Save the log4j2.xml file obtained from the OBS Java SDK package to the classpath root directory.Call Log4j2Configurator.setLogConfig to specify the save path of log4j2.xm", + "product_code":"obs", + "title":"Log Analysis", + "uri":"obs_21_2004.html", + "doc_type":"sdk-java-devg", + "p_code":"123", + "code":"128" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"FAQs", + "uri":"obs_21_2100.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"129" + }, + { + "desc":"To do this, perform the following steps:", + "product_code":"obs", + "title":"How Can I Set an Object to Be Accessible to Anonymous Users?", + "uri":"obs_21_2107.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"130" + }, + { + "desc":"SDK uses the maxErrorRetry parameter configured in Creating and Configuring an OBS Client to retry. The default value for retry times is 3. 0 to 5 is recommended.If the n", + "product_code":"obs", + "title":"What Is the Retry Mechanism of SDK?", + "uri":"obs_21_2109.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"131" + }, + { + "desc":"After a bucket is configured to work in static website hosting mode, you can use the following method to combine the static website access address of the bucket.https://b", + "product_code":"obs", + "title":"How Do I Obtain the Static Website Access Address of a Bucket?", + "uri":"obs_21_2110.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"132" + }, + { + "desc":"If the uploaded object is set to be read by anonymous users, anonymous users can download the object through the object URL directly. Methods to obtain the object URL are", + "product_code":"obs", + "title":"How Do I Obtain an Object URL?", + "uri":"obs_21_2111.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"133" + }, + { + "desc":"If a file exceeds 100 MB, you are advised to upload the file using multipart upload.Multipart upload refers to splitting an object into multiple parts and uploading them ", + "product_code":"obs", + "title":"How to Improve the Speed of Uploading Large Files over the Public Network?", + "uri":"obs_21_2112.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"134" + }, + { + "desc":"In a multipart upload, you can specify a part of the file to be uploaded by performing the following steps:For details, see Multipart Upload.", + "product_code":"obs", + "title":"How Can I Perform a Multipart Upload?", + "uri":"obs_21_2114.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"135" + }, + { + "desc":"In a multipart download, you can specify the range of data to be downloaded. The procedure is as follows:For details, see Downloading an Object - Range-Based.", + "product_code":"obs", + "title":"How Can I Perform a Download in Multipart Mode?", + "uri":"obs_21_2115.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"136" + }, + { + "desc":"After the upload is complete, you can call ObsClient.getObjectMetadata to obtain the size and last modification time of the newly uploaded object and compare them with th", + "product_code":"obs", + "title":"How Do I Confirm that an Upload is Successful If I Upload an Object to Overwrite an Existing Object with the Same Name in a Bucket?", + "uri":"obs_21_2117.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"137" + }, + { + "desc":"If the object is encrypted with SSE-KMS, the server automatically decrypts the object when you use the URL of the object to download it.If the object is encrypted with SS", + "product_code":"obs", + "title":"How Do I Download an Encrypted Object Using a URL?", + "uri":"obs_21_2118.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"138" + }, + { + "desc":"Sample code of generating an SSE-C encryption key and its MD5 value:", + "product_code":"obs", + "title":"How Do I Generate an SSE-C Encryption Key?", + "uri":"obs_21_2119.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"139" + }, + { + "desc":"No.Currently, the SDK does not provide such APIs. You need to encapsulate the service codes for uploading, downloading, or copying objects in a batch by yourself. The pro", + "product_code":"obs", + "title":"Does the SDK Support Uploading, Downloading, or Copying Objects in a Batch?", + "uri":"obs_21_2121.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"140" + }, + { + "desc":"Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.If you do not specify Co", + "product_code":"obs", + "title":"What Is Content-Type (MIME)?", + "uri":"obs_21_2124.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"141" + }, + { + "desc":"When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain", + "product_code":"obs", + "title":"How Do I Get My Account ID and User ID?", + "uri":"obs_23_1712.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"142" + }, + { + "desc":"This example limits the upload rate by specifying thex-obs-traffic-limitheader. The SDK transparently transmits the header for the server to verify.", + "product_code":"obs", + "title":"How Do I Limit the Rate During Object Upload?", + "uri":"obs_23_1713.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"143" + }, + { + "desc":"This example limits the download rate by specifying thex-obs-traffic-limitheader. The SDK transparently transmits the header for the server to verify.", + "product_code":"obs", + "title":"How Do I Limit the Rate During Object Download?", + "uri":"obs_23_1714.html", + "doc_type":"sdk-java-devg", + "p_code":"129", + "code":"144" + }, + { + "desc":"This example uploads localfile to examplebucket as objectkey and sets the referer header to https://example.com*.", + "product_code":"", + "title":"How Do I Configure the referer Header?", + "uri":"obs_23_1715.html", + "doc_type":"", + "p_code":"129", + "code":"145" + }, + { + "desc":"HUAWEI CLOUD Help Center presents technical documents to help you quickly get started with HUAWEI CLOUD services. The technical documents include Service Overview, Price Details, Purchase Guide, User Guide, API Reference, Best Practices, FAQs, and Videos.", + "product_code":"obs", + "title":"Change History", + "uri":"obs_21_2202.html", + "doc_type":"sdk-java-devg", + "p_code":"", + "code":"146" + } +] \ No newline at end of file diff --git a/docs/obs_3rd_party/java_sdk/PARAMETERS.txt b/docs/obs_3rd_party/java_sdk/PARAMETERS.txt new file mode 100644 index 000000000..6da8d5f07 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/PARAMETERS.txt @@ -0,0 +1,3 @@ +version="" +language="en-us" +type="" \ No newline at end of file diff --git a/docs/obs_3rd_party/java_sdk/en-us_image_0000001580082852.png b/docs/obs_3rd_party/java_sdk/en-us_image_0000001580082852.png new file mode 100644 index 0000000000000000000000000000000000000000..2b0302fb6dc676afa71e7e0d72a6a8c1223564b6 GIT binary patch literal 4881 zcmY+IX*iT&+kgqhkX^_!DKcir5+WK)*0LMx$kMZnm|jaO#+NF^v5NjW&m9c{F$d#PCw&u6EbQ5?xA*wKNf0>3SU68Tt%g#NN7hGl~auo1%4wa(N2^JK}W4hm~ zg`d_C2owF=e^(E;7tk7vBBE(0&SOGXqS!eFjc`%yuN;)(xis}6mPCyhMVMmJl|-UM zU#ksJj?k2|K#S8bv9MlbzvY%C@oG&rquAKD0Ft8}8kz zD9}`K4LtX7q$$+ymjQu2oRe=(A`zy+UVlwmE{goLrfl>KcydZUw8f;V zP48l)Vr)ElUVK~UQ@4ai&j~Hj^EBpm*jJ}~s6Hngsx7#`{jnBNZh9v=z`XWd#eiiS z*O;Ku9}Po=MBwM_Kt^8c6grSFJY>@nT18BcK%UTuh2_Kq%dx@>x?lKk0+HT}A1W3- zn0iKMU;V*7EROwpDc|i`;_f`1TyL3pksE{YJ)itYZB~)ta){D5NS>@|KcBFnZxQ+&|CqUZcAy)&X`*&a%mx}k#K;dDDLg?zaOzd> zQIh!4bG?IQi%RiqUox~uHEB|l0vum zP1t+t#Q!2KlcxBhq!q2Y_y(;EH}Z|G(0B)DCUzY@N~cN)AGcXhqaeu1s+D#0qKl=S z?5TK4BjaEzOh7b6c(It z^6Tx>R*Fw)zePikOp{KB($C$#VJ(4m7o_c@@q8 z(seJ950P)}I$W{)55J^j)cBei7Tsa~!dHFBd1m&~L?8ym({$R`z?&@=whC#H_|uyJ zc>DqUtNO@yd(Uyk_?$id;jS}uQ|$f5XnNog-EXulQ{lkn-1St9*SoBu_5zh~(fvW# z;}2aN`f5K1x6)H4Nbv%0vUV3envG{e;oOJuH+iIXBW3`%(wgA$q2I!AdEMWSJ2Od- z^?p&YVuMhMuZ>Y)E@#(#b#FF7eO@%L2t-fi4B!6+kj>h=8;-DBsdI9mhaQ!iVwkuD%MWBlzlWU=uPM9Qjv^;C}Xf*F>s3d0{8$yKfrlwE!pWD-|y=N09An)w)FO}TzdhpZxU6ulQJpj@8 zH5-XJ2+c=VAk&bI_<&G%n1SbJsk{U2VFDn;%TVYqNm=;;G{&nrIkG zqht?qX4-7NjT#|pKRrME3uQIP;a$PX*v^R`orle(CF)|{nEiSM`Ee{`%qnjlE{nCw zbtmU}p3ejf`9V>5!5g&!jYKkFh*Y+q<+8bMkDfS6nC6`lf1uJ^@L=1NSDXYUs12)= zZ{uy}*^kxb&o-koka5zNx+JD9w}Z7=YGA4p5Iz|E6_=7*aH6rn_rN^C-n?J-Dm5!{ zimCUw)_P_|E)sH-TlWTX41;@gLszH263Skw>;b=U6{uAy$=08(u39bh#&xvUuWXOB zr*iIDIQTsD*WnWH69gU)_}O%3uX6L!HaL&8ZxJYFFU$5i{?stRQrxN+KqoW#JNOhy z90}vrN~F7xe@-~pB2SXBIKVfzYJgDW;J3D0ZNb6tT%?)2HFa?=zTpkmm`Tjz5~c@w z&(??A<4Qq;^s5UeC$!e*Gi8e&S;RI)Jp-0$PZ(H~YDLE7|*2SoJ# zlC0dtuWgZe_V2Merip6x&+(#AQ}mMTLZ^N^?h0qM@*Hn@M6$cnm#tXd%oi*gaQv?2 z2k%@nkK-o`Mzh$PP%^JA|MyyCS00*v>h8uRfgrQNRGkYZ;qMiDKKl}RNQL&{lV5dM z1Npd9WKl!*G4-Yc#3^;^T+iM9r6VjpA+}rtpIlei`LuEW#|Q^;NNZ-_$sbnhP{%(0 z`sVR`2mD}`@XjsmXTO4!HZ>mY4iqKexCse9yV|yyjyVhF@y_2SP0>}*K3+3nKpC}xToFF65xtC-Atge7lB{7?dL*n9WhfC<#=m$!&y+R z(_TBY(9bc)xf9&q_wh3^^8*61pu;0Rkwtfoa_IqDl86EYN$?S?aU~Yoq0O&&r(&@h z8V=y;(s#-?zlD2l2>bJpHBZ;SdG6_XDPbOovl0ozuof>4$n*-uTSDh~b z66{oSX&R+{W0trz^{zT7VfbUrsbcfL8q%eo$F9lABJQins4oK}#^*dU+F@%s@Se-G z7;i!m<(qF*x|@5UeL>!8y0O1%wodEHObUSG=0++dxPz_2Kl?&vHYpafuaB23C>351 zkFE5sh4}NI_-@OX_M52mLS}lJ)`(VyBZH`d)+vcYwkSl}8!pSFHHk*^j`%{=8T^Gd z^=}$YFS280i9c-g4r=SE5|X#}!~n)~?bq)E@-cSIh$Cl-r=VBtP}=9g8e$^)XKR-a z!1qeRDOuvixS|H7^>FY?!mKX`-x)wvgYc8vWkb1x!9e(S$F2x5r7CD$_4V|)`2-l* zpIxwOD`lp#CA{+RhZ-4n^Oj;9bHx<0i9bydXfqg?W* z`isw_dxP<}GH4a3Z-#&=kp6K~(~eDd(cMzVs{;lD!Y)KTIB zRZ{KDBK%&WJB_(z+W!<&Y*j1&DhdnbfRHEGYbD0VqOFcxLCo>T;$l(jRf*S%W=E(F zH`HP25zZPziX1o!Juue!?8c9k^G=EgPp?>BRytQmU?NZfA{7={lCe2dX=Ed*sEd%y*r2V^j? z8OgzUn%-rYqvMG%)Gy;P$6ZhJOWHVKE0@eLJ#KkT^j*9pRPodMD(~p3W>}C(jl0U;86=!^2`~Nil`aqI(3QTv2_Bv`dC@+j)I! zLIx-!8YkTCL~f^CrYn7Yd$H2)+61}}l)toC^}KLy+Rv;f8Mre-Hy@${-BIq^Qt)g2 zgXv7pwC=kasM!=~g&pR-T7lLzA>s5$w%Fqo{wZat;TCN@#>mtE3H2C)GCE zv9PvuGG{g_4~=MC@K86*$)27*Do2F&2~w;p!~|?jOpRb;pRr=H2rCeF>jm_(hESBgQIBd;I zt&Ipyif28Id=G5apJkUD=b}*tt;c0PXv;u$AJENXA@-XI8ICTQh;DkrR4sA{hh9!^ zc70l;$*0JjI_sm@)PrxnV$g~KApa&-g+?{wflDTGc0Jq7-uDrrgau!9Vg}n8lT~=g z+jaeF_QX46ewyiTrfN^o&cZ!o)iaGaprE*K(Oz=pbdfNmMcHUG=AIeNSinL znP8Od$*Ag!*XvBhCz|Be>_f}nOtp#2NkD?QH06p*u-=wY4rH6g$0}eo21a~QviA~B z=3J(t3J_vzgfu$|Ln|@r9{jg^$u6pBrxsUB;XT-I+D^!|;HA4q4?k1?Kn15is}bA_ z49`S5S=tY0A_{)pEE%TF05V7VyvrK)x}i_&hTnjg{QHopI#D!o5_w_)&79ki+3nh|@IGnen_k3@e@c5Fsm!Rb?i@6i0HRJ*YM< zi8XK{_Z?jj>F@Ft+bV6t8(O;-#${O9WjZF}-|Y3jo$icwy%Ml%PBB>?Ch7^fzWMQ^ zsn+w<3#)q7^;+7V@g=evcN;eg*}`|E>fIgq_k<1nCXjL*`24AusAw~+k@D^7XR4yL z?43(-u0dRqx{*-2qLxfPxi!~b9c{z%9X#2Wg47aW#3`RiU@s?yR`kbO|PzuPruYOB6yy7+&abTMNbYo+>k9mkS}{L|`D z{#Q{4$4B~ff+gX{u`G7+Ds?}x3hU~8fI_Pw#%2Zuwr57wfB-JLgP!DbFLNxR+5=yQ7{aIc-T&@_|ZN_&SY@S zc#{JVQ-fCm&s(OfMuIX>XWMdlJsnJl7CnbZD8|L9)`Y`edl-o zljrMId5wY;lDiDgrdd(FaobQkkl#(#KL$un?fdU_H_PAn^uD+MdDhMJPrTxvFL6I? pp>6?*p1UEJ?`ZH(zXm9DdwDRQ#KpQ;>Q)zxzP6E8jiy7y{{Wt5tWN*{ literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/en-us_image_0000001809221937.png b/docs/obs_3rd_party/java_sdk/en-us_image_0000001809221937.png new file mode 100644 index 0000000000000000000000000000000000000000..1a8efd0c9b1c168640ae67e242b9318033cdc4dd GIT binary patch literal 22593 zcmeFZc{p2d_b*H-9qC-EhPG5o&BeDA)sdoFQz#Los3FpZn3HI=)v8vFG1SljHO83K zl<;j05vny4q*b9rq(VXxN#5x5^f}LY&+nY;ocDUq@W=VXj-6}ooprCZ?zKMav+jF8 zy?*V=&TWUbiHL~ow6wTrCn6%|B_bjkw?#tujY(8|t?)xM*zU@Ck&4fU=Y%KXzUDUO zA|h3Z+t+Vx7M^dtYvB?sA|my1<4?2$^8U7n2w=$aqPau3J8gnHe6|BP!sZ#~E-Vs8 zgF{#2cqdhdB=&9J9at%8fZ6MDVJQ9;QG$YTYJd8dyMegsv~tH*;^VsXvj@^oO=oL6 z4~?a3-3gp~CTh70B#vp>lBgmVT;+Y#`jl30G~NyZpYH<#fsPX<{ma&%N%V60GQ6;{ zp`@XqsL{0F#6)mOR4AgzhY)e$phQIOZu&p?^X_@%ujdEjk?XGm+SJLgy0s2PoKy6r zW}zX7=d>k6RFB>tu|oO)*4c&tOLrvmOtx@r-G^FbL|#2{+r2ENgBnuA`3OxBbLN3)d4Xb_UDmdoS&ZXewW|( zC&$4$!#<7g*V&{aB9b2Ku|wqYxd+03D^CfPsQp`$r=*2XNDvVoM2HuJA|Bh2vxTuM zL9}Iy@E}ro_Wxe`|BD8+A9*Zf&c;s-t^zeG&N7>FbYIe(cr}D;e}BQWu_GPJ3|W*G zOtwuN7<+Q46n5|PWr>(Q8@6e2s7RQ&J6!Q$X|c4eXBDK8i(qXwX6{n6aL(E9>s#ts zXE$ff>xtoQu{M+5odCwpwiROF4lfHZu2G}OkTwi0f3!nnCVs>E9%`*4U}<;tibgL$ zlZDFGuE}4&^o@N%$1R*Aj;+wxS2y3Dm9MDHZ~XqCswa{R-O}DLhEEi=-nk)2jJQ`= z^i+iWbb<*GiCSIFX`Iqu1=R&qCHiO=zNzwrVVo|6>7Q`CKYA5(W;;5gm@=exCuI)m zX!G2Sa=c@vwlE~~=!v(lGBa>#u5?dt8W|T3Ts&arnz!94g{kg8$u3d5!q<{qBTz~r zySxXfP@S!*;0UNnf9h=dR~KDgDWjNDGCaX~OE%qA4JN%pQK_>;j3Yi>;GH{1*JJ~; zodR5ZN;j33D3-2Y^_2U>b@utR+(8^k}DCG{kKj#D8?$wu0l zc%x+cne8*nv|{(o;2Rfi@_hXp4y~88E{;vu8dz`{FoII_+v6Gaa~v;9XMjCC=nP&V zB1gR=$-6{JeFATe6TOO!w-Tq9l? z^BKn1I~11RV6X3qb~G=W8qS`ONHYCAlUQ44PZp686NUkq`zOV{7^mB^r~Tq>rP-%1 z>HSJ|ZTQ?f?ElLdpK~>6sZW~qh2ZX2DLdWu5b-T8Yeu4?%I~#9rqRzQJNjz+3v!ta z=~8~6l8TWSV*s+|m48egByefbZE}pH(dXufekTjG{cvfqwrT5{Mzk_V5Z?r z#6Jccx!LP^HIH$W>Ore(K1-l@v4NRz(wH6+rS3K9X8SI&hJ6goe8-h&k@+3QtSJU< z-(k}2x38bXY8zBXO0S=2D}3sf8JXGX_;4Xa_VkspMQT6J0jTEd)sj<6PPd;yk;X#Y z*~T?)?{Xuxj{{|bv>=%a21N0l#r)3nSxXJ_`+gFcgQ@f72WqDa73&=pRFhQ=!El_u zIT(l(ng1h@9*{el6#>mo8$WhqqjkBljwA%gGBBZn&n zLS#Kq{jmDuN+Wooh4+XpUgZ5fP?V0EQ?D;CZ=R@%3^{`cd7loW7?9GbWdGbI(~u~b ztNYk-qE(bi9tTwZjF1@+P=@DHdL_J$*3h!xfrZR5A54xn`DgwqH&v0M%Ns&fj(e0n z^GZ;N(_9`nHV&tf@e^#7jy}A5ezi^7SL_1O6}$H8HC6KN)qe)P7M)KOcST#m|0INt z{0CKz%!gJYGIAR(B)XAK(&IK_ON{UkLpieH*h(^DA|4T2+C@CXg$EI5h5tpDc8>&M z+k9#q1*EM7HdXHB&z9R)c!7r5p80PMc)Gqq1KJ|JKvHES)<~G5HW*ayU^KMtl?eAP zGLG*1Q6Wy`x845BK>dowF8RyY*j{V~R+WCghQqby0e9vMD*X&hJ1j1Yw~yk#8zonN zesRFLJ7wD)r;jTx!LG0g1vXsCuf~bn$L`*QVlRB;O*Y2Kc$$%d6~%RbtELd@z3{j( zwC#BqNFxX*@LyV~(Hbd^)489qt;t{PRr#R{R_A6UzOv0g# z6`U}%HrXid^}+48ne4Z=2Sxq5d2d3#aq5zq<#pEMIP~ZlZgQ)QzxGUTO>BNoM3s~I zeO!E@PiICa(9zg_nc{RBFm%}lG};7BD?fCuxVme2k^X#}LExD>b*Rl8^ijP^MWF2& zJssd6b*RYQ=_Lpq5O~wNtis;}2G{Jg8A7kY-*hDjfaF3{>HJfsZ?tQ@cS!nrs6EjU zP2ze*;S2ySj{ZZw!>!cq_$HW3682gs-(Q2+DJd~%E%s@ZdxS3a!qZET86_;|+2Yu(Uq-RN?4hFxO?;+5WTovKj$K=OEhpc5i?b z3+>~gpZE1K!y=I6dUf|;fn(!=sF$vt(j*<{-uqQ@J96UpXT*}i-!NhpJ-=j&S9 zp?EzL$`rYQXAz%Uq2x5FIBt4Y(7b!2)dP2z?}LX4irGV{XkuB>j?z-Usy|V`9>ZTD z-n*UYA438+7Dwc8-e#gFFApCyH};MxAHL!KVSO>wC;dxS;9t2vG(d7+BB1@u7(n^`YbB?+ zPw_67c{GWLqXrtOCF<3=w2eFgf90xaXWMM%MN;d-B%5h<4i}iE&ae^&e1{2n4x2@L z)(7Lnoo=)Hj_~SCw45f_IdOaEbU78a&52pdHPon1PVt_bp%1EJl zW1I^E)PqkA9`l?QvwPOz52`+Lh-hMOHiz`H(UfVFy&O!98sWgUw5NtEcCIXPyUdB{ zRM$KdC`=!uF^oZOU|sD^_FLM8xz3Q#zb{XL;TNy_!E#5tf8LW>35z7r97E^R>lAyW z9JAF^2@vF!I~W$3kJz5JJG)SY*v$l8^vWIXsHfcI)~Lt?q|#6aT_n{<6|V+Ig)TgU z-qb_pd7LuVvI~9N92CLEznbjRsxl(_fnh8+vNNy%)6lTl%Uhm-Cyu|z7TB))!BHB^ zlFNrEpD6!QAE5n(x%B71TYH^w?~v)TN?GQw& zrr%p>-cjN0@@BF6k<&>Vb{^$`&v+y1d0m@(>M2GmzFw|uV#s9BeFx-;9-6FrhpU;* z&c?j}uZw7pg%&V@;Gw{4xfh^%=!+8{o);IPqnAUPIBW7%ZID^RmU?> zz%bi-WC^W>{_)60VQ{Q++QZtxw%J}xlZ#}o7~YE2%f#Eoo=GcWh3Lw<5o)1dZcAL( z6mZtZ%b{A)cZ*SvQop_ly|Y8ziw5cNeL1;v(sWL^@6m8OcB zNdKptN5#D>#b>wNqDg0^5Me)U>jL4zaZGctS*mE`)ho`(60L=nh6OBC;6Fp(pYZeo z$0~_44{%ziNP+SqbE3-V`P>U`HPQ{Z4teBFgbUK0=WI`wtozh(W!1LX=I_v3bH5{R zxvXgue_c|KGs}yrY-oBIjfK`1i_xwp+hxoiv;@QaED>>Dz2!W!vR@R zev;`4|3i7M#T~;4pKM=Eqf|A^E3{~P-mM~ab5G!yKDPp2x-`x zE=dggHxZ>C))g#5TJzPiYfS9tgN?c)wRJFzx5|II-&GsqLX>u|aMTWVFLOk&zgz1~ zfSev25p-ilaeFUuy>F_=a-t z9F-BPjDtVWLCUUTx7jr*b&Go!=NFi2fe=7bh|FK?{iEw!m~-FIo1OkFA{rAO`*far?W+c7_n*7Kep z-Vitc_q|5qUYr8B$m4Byrn%mA>qcnMWARgJkmH_TTN5>GtG$WR@0PP7dk0pW&oGS~ z-RmYb={Gm0Y~1ew5*|HZ5e~enQ${lO^7x%8IgUwlj2iK$5u754Yac|V^GQJh(*tvI zyx4{3@zY|DVXW8(rkY;B8Sm0OOcqyZZr22+1ILZ=YmC-Ti%QmrIlBS8Hei15S-?It zj_!YtQanpbJ(5vc_C4iHX;sd)qtivAD}#hO_M9l2^x|;OS=k+3d(Si%MO=IArvKc{ zTfqY64M60YGgCO+ZiH=rC#Y^BsJD^#I4^V@mRa-(C=qohsI-D~3@@#$pKG_>Ls2*i zVWh3s4gCmgoN8}GA21{%>%uvs2Nwn|WVGIyXE{VvdqZ0ejvshtwD(CdzZjM)jz#3n zNKO^2rh1&fDdjz=;)MB#E%Qd`)SK1@cfwO6b zrcSI`0=XoSmiXF=T>%+))CcB;)m6iJ>-c`&zN;wpJ*47Q)-#%9m7h*kLkY7CQ+(TI z@Lwosv60+{O>@2MOMn>GxiK4>&Bnv-s@T?;HcGjJ)+mnL+70~E#s7e7JT&>U@f>P( zOo=P>I#P#btSh;BY}cYaU?m`;`fl5)JgTI%+&>HMJ>RU4{O85Cw7$#@vCP4G@q>(< z<0+@>cdE$+W_mM4-c#Hge%VLcKPn|@P;vGJ5;y$sI!Hb7r)e**9qV$&3ViXOf(o0g`TT7N9r?21tr5l@P#H5Os3#wRzA0`30iKE$q(q3 z`VD&e&l`6nqh|?z86jC@-;1xHoL+4X>OXQu8h*{ti+3o7Z%z*T4deQYSTE(=1Fz%f9 z0QosjDdWJ^!Tm11EDjIaWcpd-U~$o8UKM!1pDQ8n;54;wBgbE!uc1!cs;$mh@aHdV zQm>A_>64TCon@x=#OQXmeiv+>sLv6v`OTkcr+F;2q1ZW9(;g}nJDm6YNRRyDBY8RL zer~R2#1P}lGqp@8NiqWZ%yGYS7RQdr>3>68;wS|ooiOxu)5KcK^g-H_oxi+8QOp3L zs3qeIq4UkWfprTr3=>>ZF&%k)9+Ga)yoZ|r^JGa*OmEHt3dpL9UPUqNKit^^?_ zf+QE6G&Nc8-}kmPW0B~i{qlgc!g<{<1F@|G=d_GPx}__#h#Yn{aj39u{<*a}2?FZy z=3K)Y>Vnm%2`j#{Lgl(ri>_CUTPWUv7fE{ZG8Ra;Gwb=!?sPA6{=&KiAlq3yH$@KR z(oky`Eue=sTBX(H*R$UIpemPodYnHiUjwBD1YAJDQUvzk_CR6DnNbuQs{{KR$W^st zC$l5s7}Mh8_{m~7S-D)p%BNpqQ6A@x5d)b4t9Zxly1L`ITg!&+Mv)CW0=+gfg#l4;noo#a4P0LT7V;ph+7^?H183JNu5 zP9Sot6-}!AjyeKvo76B#(5`i;Yc^@-H?Rr@Ev3&jO>8RWU(X`xIlaIlvhcQs%Zhsv z>dO0Hb3rcY6Fv<&ae;cSK~0uEF7@YqXJ*ON41)(c9$yDMoaDbT%}qm70jlzu0OQ_^ zg#=!?`&=s5Iw5x&6I@6r}C6%Z}1ia3F}PJJ8au$PQmovXBny7HHWu#e-H_>Bq{4Em``*rVz2vcr`<$y~JOe62Su z9PQPxr9Gz2PF1lU3*6~%7~0}wh9*9})B_N6&#}!BPwtE%9uP!9pnJ)#$_`M`OC}$*g=*+Z2D+<;?I%n!s!YRLEdp-> z%U)=2xjGo3;x@Fsy_#0G*_qMcs+~UH7-`B3BN`cRB;?EU)!PW_tKF25Y4BP23u#v)aIPEAcpTdod_W++H_eGMHV z8lZ&_%ftnw7vCNl6*4`)NuHQT+r(1G0t5%lim0{MHLh2A_Ft@RQu<&i#D<*yL8>mO zI_K6mWi%!A zyp+qYV5SNB4Q%%>F?t!vCWM;G|Y=75VttBIYBEDcAkKeK2~qP{2uu+ukb^7O=A zJsxY4Nx%FkK);i?gVjvW1J^{@H1k`=(Y6xpgh*R>R_40Mwso;6B zwyd$3zG1gQ*|Tfw>&5uz(PxtQRn$d85Nfw|ztm!5G%1dX?p$Apygb&|<$8Q@aeT!g zZv*b!QjF_AU)LXBn%3xp=cmS%vt+)%}^}vrDfV0);?_? z7A%)t542~g4`aP%;_0h1WoNS5%*II~UNbgN#sCDSt z70Jrm|EM1Rji+Jx#SfO>c(G$9%RFnx&lL|hexlUvV}~NL#oFwu$J6fzU|tBhFu2I! z_#IEYzzbg#b2t^tkf*1GZr$Rr1E_bD-FJqRb zS5G<0T-nxs$eX)?O0KdbD?R?yF9xSgL{eK_{yLGca|AQnc6ByQ;GHicOMCRd{Ot}2 zz|;G0PMWa@aAJ$T>lMVyu`TB}F)lVnR;qcg#opeZb((Q8WUlcu^%ji;+TFvhXC~CD zq`LlAgYg2y2vkXKFMR3%tb!2-A;go*#PTNiDn z@BJ3ZYG?aH!Rh8-guuv{_Y$E{^;BFNq327i8G#y<6u%=}e|alj-3yM$RXCyMbKQ^V zC@7K;Fz*Kly;VpV-i_T6Ss-7s4)q9>9QBqPWVk04@ZrNS6E!XqU>|~jn*0D46CtbN zjs5-h@B`EzxABqYYyYJ$vk6F4nT!)nd`R@(DV zmr;@QQiN>nQ;!`P2OsEIZ)%nCTYTz~aPcV2Qiy+=b|u`} zBYbwSt+bDJ=kUz zaThSYG6`HVp^xk*Gtz-ev*hTel__E0M}2W(KavU;UV~hF6YkNdj$3;k&V7;g4kwMg z1z7)?_G}7L8ro!6H~SddPO{1ZG%UUVE&(B={bs*%flG;|wdx2?|G_q2{+)vpwvVqS zng!ozV%s-PDI)Fy*6Z@f`^gcBepkxiLbWM#d#&j8U$`j?0KxZ^#wmNyb2{?Ezcd#t z)o#kCY=>_WY&VlP`w9wexUu=X8ROUD&)BJ6zUtl>ICo+x^ksUc`@7_5nWafpt$6bD z1w*d#$ys0I@|!hLedia0mPh4}S>8RaSP7r2UqjSG{%BIW!^7J2416MX@F~}oKE59* zxDUKHj0Ww?)^gvMcYPWEOLfUR&O-MboRO#%58{ahd(R8_`g&W^TPtg4BL{Pl+$Z&( z2VD{5T1V>2-o(sOs9oZ~Dt;WRj$i=7+Tt*cQ#ymWs*X7qc7C$_VFPtsSwaK%Nee3K z)uKs0fbE|lI3(cgO2Jw+uwUzJ!Gp?G2XEZ8uV(x(G7!+j#cIZ@mrRncGeN9DkG`hl z1+!{J0$-UsNHr^A)kJA_!LL2gJ=5NvKB4-@tukD-SuL|+Z95HQ*i!mysiZ<>i>H+4 z1!X`PV&TU@N?HSew@|V62{0AGEwmNdC7Rr5Q!jX{2C7KlH5~f%iIJS1Ij#106oPx6 z9#);#so?=70m$Fn7=oz%->hVlZ{wrL^aTn0Rr8~5$qT-U*E`q(_G}6KSBIkfjGF8} z9rEFs&0dUVnN|5TB-836DB_SBA+6EX)WdWl&Gn!e^qXpyGR_mg0{3tf1jZs$s;x|8=(i$^o;@2(( zZ9fLH#jjDGO?g8Mxu2zrW6EgTG8bxezoo5{mp=oSIu$=HCt08}r$c`MnurT1!ME5r z;ANf7wayBA zPNGb?R~n}p$+uXq1+#nE@Sh!u`t0fAS9oUNS?Q-C@hc<{{sce1ndf9W9Z#A2S8TC1 zkx7a9WRmf1lAJIr8X^oifw&*T752=fS}Js}pcd-S;pAkA{po)Km+;|SU+K&gx*S5s6uHeZNF&6y zAccPJ6XW5WNuJ*QkyTt&5x!$D@xoD<4c&p8vtY}({_vNW=%^XRKcgEju&iiFZqJ?; zy;hyq1+E3+CFg_z?jO<4UaDPz2VZWHVsBcV<^PrIt7chY(W&Ige8Kv5Rib0jcn`y& zN~oD)+hq09MeN^`>`_h=_G}QV2fvKtgzWK4n3E(!Si{S|Mo9Y$DWhUHKCz7_Jy`B?wAbl+%hBEpKbCVxwNN z$YwvdQKu|Lj$^|JI7)8n3F%Ks!;Bvdw-A;yCh1y+s6`k!iWc`~c{XPObH-TxbD-kc zH-(v|XC`n44n`CmCYnUTnK3%wwrTWX)tak5YJB@6HncTk2fz1rzS2npXFF9_Jpn^f zh^s{zU$!F~WJN{{qUKbz8k;`=@)8C`IzOW&iUw=-(&)R=jW$8w7tdpU=>|XO>8pi(AO6;+f>|DIGSy zn8FyhI*8{}I02T4XYV#1`ZmT|v)uIL69P3hONW;OL+`a_U~L@xI!=vZSn!G>*oeEA z#YcKgoa*Y^X-?xOlS%xaaTrN@Rf+Pq##SlT#9kI0xWv9V3PDFVoXUGLM3PZ_Wy(0t zJ-JvVc}@d<9ME>VdEQp6bZp%hxu#->@chhC&=2AK5@)Cl;a zS~A@HX2&H+({PiptuQfDw|+dcsX}qD@{?a=uj3PMBxVqq^~{@r+B2JhO!X`NQ8sg3 zBR5#1AN#dNUH4O3_283Ye?)AM^iq42cNeqMj&h)IWJNTYyEMv>%q3zvw*rDzi)Yb6 z1@ne~Y1ortmJUT7j8&{rA`>7uzJ$9JKxYfdQum$B_KY4DH#A}dJ)sz+5gQU4~Zqye+qL~*`7$kFa_ATX_e<5s49CC5<#oKEDgQH`eK{!;MJuN`qQ+u0?>*?x zdos3e)V$yXY5Bf$%s=lj)^?SOn``!Y`60r{8N*D^2#+YX{kcp%TI}v_g5=qMzkD|! zg)GHh@^R6sH|e%fClwCSt|;m)3ntzUMw=yyzo{@Oru+YNJp-Q5WXDp6*yZp>y7~ zT=25}$qCG-&|j=LP1?1=TXuOox4ygF%YlMa?<|@FWvIfsZFSW_K>X3-El4JLn4vdS z`k!-6OF<+$0(^l$_>lTS7`|DPHZiNw@rX}<`YYac6-<+?L-bLzn>-Kr#YX>nLk$rH zM!RxJ1!{U^TOg|(&T?rUe+fTHdBlBqwfa?bkuwVvY#df5o%IKZoyU4u=U5X(AFf&k zohd)`&PnwSOc$k8(FCi!S<&@lXHc`bMRX)@?=&4FeP}I_Ay%6yYOU8Md8)Xz!p}Am z=uaF|#?Gw8N}>Qr9Wv2Z!d|zfxT|5-uv=se^SqJa2%#sQ4IJXWuUgJTqzD1#uu+DN%yDLoI zdjz-s-D}qK75?1(Dk)PTgzBfkqa!Zzx==m1wF&xlZq}-TI`Qc{f4K}edO315bzaf3 znLDnfzGch$G-MgG`fyaWY2CdZIDDzA6pkLG??vbFew?q_S@PUlwqjweN@M?%X%1na zsL+>H&RccSgFnG_(}?Iw{PWcegpAFgVLkl*KjG{7S&vhpx&h)|8me&YtFTQ>$rFWT z90p}Ysq!w_JE=paqsyvjEvDei-Jc&c`KRaNs`+b-!N^F_BGfeNqR@4KU#&|~KNQ|8 z0ltjuGHLG$Rk&}})J^jjP0dKELHO&jzH-@M&+nTyRhm|Rm$DUZ-^8sobk59 zyID-aD`!~6;OEN$gI{-~6qI?{ARQ_*WwBM+Jg?EiCO6VIy?ChT&>hEqfAH0vB8{Kv zW2)}iHtxv$iCc(Mb#*ocYoXVR!y03ax+vVm*^e|i0?eMonUtLN3q7unjk=BOUBR!1 zH!Oe{K%Ijbgx)LBOJZpCWv&=UJB_x&$rnUk8jHT0r)oz+I1b5muX4UHujGMq$_(v- zbRi!=?HrpTi(PN+qRi@Ot|nNT4yVu6$rj74UN@bDg)M|Y@%m1fK@#BaKh@4_fcA`S zN(v<6XsxOzq-CE?m1tHftt*LLu_I?VCpufKU>G?duELQ_KBl@H5-;uCCl+_nUw)mb zc-JbKwAZ_Nk|k@b;f&4WYUnxRn8ys90|JUbw*J}!QHY~#5`e;#v`qHrebL1yjg1xB zLGO;%3C-R$$6H+%`n|AKT@)u#+-4^g|D02R^m5+fwp>3{5@9C&LXn#JfrXveP|+ z_c}4lV*y!Xs{!xu#UI{T>rV*ipQIMpYs!$Yy?cwx$EVjhT)RT%=+IlKb|d(ZZ!3B?Y%4nU~t)Hf&@OW|E32fg5tv^(`MjbrM4g;aw#p2pUO0F(q@9`Op3qLYo z{!*1VG6J;tU5f|x+V!KT8W{8|N#+!)7>q#Es0G#IGe%)q!c`;SVwzI1S7Wo$IzLeA zFD;~SuzP#tNLV41(um**n(2DnZ*W%F;w0N;`6lA(QLaMN-;K{T0+D&lzT)~`#mU*H z0}Y@$aOupwQg?_ayLwWp)p?euiz_EK?tDN=;SEHPuTu1jUHD0yK3fc$A2-a;nuO5P zja65gr08O4f9CbV{tX?Rf|XqR#GKQ@lBwF1hoZ4&A4=gj=XNR_iruf(%rV`Y+62NG z&g2Dx`)t3dp(ih0TQN%Xi&~f_!+@SdjP&0Qb}(Yt^z`mAUHbFHjQePTbCjhw8RgGA7Fc@xkU$%!IrM@qmV2qKT8O|4F*E5>(wGGXZjIiY} zqz#zJF?FCB4?@2pnjXU6-ne!Qa36#=YPTc#-ED!IE^VVzUvHpgWHTd1e;IHC$P3%MHiWmysoJ{i&rZH)h88 z-?rE3&({~9DV!Zd2rN|0eln=p2N@Zy*Vm`X zV4#uo;jZ;bk&DSUJ0u75zdy!iX}uEoM?8CDsQVL9*-H;#uZ4Kc}&_07LIV?7qj_<*yC$qcrYq5k)rUa&$syc@FlS9h|obq<%A*c%>k*Gl^$cM`&Ut;*+9n9l$>i)rJbu);ty* zM-v8-HSz>Uv>D$uI1Y75>+N3UmSp~Mu;~X?u_@z+-rI#tidf?Gn9Z#8=G75W$+|Mk zELry3sy}J>&?RgypXa5RDE-ieVJeG_O^N2eC@w%Y^zNhmRFH-+#Nx_O~SP>i#+{3XzU=m5HfRVe>#O>`dZi*Iwa<*;#J z9(4d?YBC(QHa(cPU0Y&)))YP-MUomr*$vIclWP_I34?AtxzteivmYSG|I~I@cD8FC zG5Hm-H-P}@>ZBiSVn3+9kIIb#hG^s9>&1My06xahCX1-WKnq=H?)7`wYpD z$tz|{&e0$!9pzW(qUX%MoF2?Zz^os*BUVjsy`o^ zX^GPcYm7MeSV}WUBWP>ho%%1ziYGev14p$4eG`pSdqK})H<_=K{(|AKI5#5Dh-GzXw$@s4PlCrH`O%aY)CsJSB;ReXF_`JDrXfxFDM*ASf&e#Z8PYJmYEv_+R_%RM)Fb1pbOE< zMWJnB<6u@AJ!-XLZAEXXsaRS1ayX^ghmD#HzA?`JP~UZcXeA`)2z=I%kOaX|!9Hf| zc@i8E;fl52l<42D9_Uy?AI+&c#w?eIWu??c-{kZv;!c?UVy~>;dXY1YA%vOUyD`p5 zQu9cbeDNt)B*G$@>>9-;*|6<;%{X5w!aICB4!%s*G$ce#eb)l+6R?t={U&3i*{v&z zoS%FECf9*jj%-a;v6T2|#{YR~=^4mCQR-9rk%In2v#tx_W628us5)jmd2Ji_R*W)R zB+7;^t5G51Q$6zr>fClR3PnMFt&tsh;lC)Q=vVp%RZgA^3h+A zu1e&!^k&n)et?@NkLQjsF`qEXSd9i%od#vBN!Q1aX@kr4j|_%P?M#|2ny+~EqjGNx zl6V#ft3EjBYXN>q$nbvEYF{P7h1B(LviM=WgivM;XCd7>^GO3Bww}WFR;l;4lh_9l zbW=>+rU_=a6O+t`^(uBas{;WC{mxjL?t7{3)e+wL%&jVXEv)AUUBGCZVx}-GA5@Km z*qIQ-5^tNONQ=I>w>kZf;l^Wi%n0SDpqI`eP}D`THaTZ5<#x-yYz3=5;qbcwxQ@GJ zr5?Z(H;oi}3EZOYN|0+p9qKfCCA~vy1zZVmc)5}}Cate%NDy(UxJm>k+2L!CZ48om z26O7<9B(by2N~%`19ag2(@!QpsJf7{Bg1opwx4_XsmlBCpJ}_P)p_+(jF9V>KXxxr z_R61_a!z~5M91T3l0}EbVb}JgKTf|Z0cN`+!$P@FXHQ4^y?;^B;$9Pb#g6ZJ8j|pT zF6yUroxeBCW-D9+40kq1=>11hmxx`iTZtBtWatYqIWU9FFmJY29~@`0qX{?0crp6L%f9J%;D z=uu}H776T|?72J!R!x=i!>3|T8hC@A_(Y7)d`&&9J;#I{xNa-op0K`RhWO%~%uckn4CaG}P%;@o?QpM_!l@->@|a7#du` zM@5uK>Ax+zl3mJ>NVuUj}iEuwCn4_FpS7`*d9hdnTR>g?ZvL-R2qrawKR-b%;M z$6(w`W3vvAKM-3?(ue4GP8hwG`r^;IB?dV8(b!L!NClyc&C3QXy~;VT{jbik0`S`w z7M@z60&J~k#1EyxToLp-p^M51ae9?2Agw1j_^+!{@DzK2Gz& zD>%6y9RDnKxT7kzilorw(>pBeP z?zlX#U2nKo?o`o(@-_AcSKftJRFQ<N9F8uWeb~E4^1R$0mM>k!JIex|? zS=!K_i(iP^vo6U6(Js9F$Y~lycaR=`uEMHRIzR)@gf{Rs>2zV{3RuMZ2biUv86GlQ zTdA<#+@S)05iFVfv#MX-_h`rIupQ5%^UH{X{p*yQ^XNfIkD$xUoT~QLUinYc{mSrN z`gw;PB~QU(7@7jAZDGiywngRGgR0vmN8elZo`w<1H%Hc|v$90mH9_t?UCGhUt!JPoZ#<4daz){_HITk}w*TGcd9@cXT^rNf9uC~XjJ8@&BVbVJk+S9H2q z!Z76VdM(y+{>gSuZ?ocb^GtaN4gNEIG#on?4liPkkyo{P$uA-i+MT-z;FF|D61l|n zkw{3IDQ3qHXhlNXB$xGJx`&Y%%b|}gwWm577qZ*NmWXNX(D?5DAG?tC(L5$cq`Rk6 z;oA{O4s7tB4ZYvF$%Xkq!>Qzo97%V0ErF$OansN(~|CR_*d|-UByYQ zKri^j6x?ejlctR3F)Q4Mu|(}@`w0l#ikITPx~gM;wGOtpkWq1L`u2g_xrbZETgvx3KE8PkiMP~nm0R(q-V-|y z;wT-~P>npN-#@O(K3-ocYR(?5-f#Rqy;OqPT24#}g8V3Pa7F&~p1R!v!GH=)*`OIV zsiI)qCt{N77IlpFp?mK{ctye}69adf_&i&V)X?6m0Y}kRo$(5G?!lvl7CA}0F1n=1 z#9=*|l%kVetA6OS@c5#Wn8PT4#k*Yr1o{iT@6`wsgz4+gwRO_!{T-N_ysNa>(;_vx z4IZb?o|qF$j?@4&t~-1Nh?T2V>h?FNiEVOps>oew(YPmKgE2Jti-ve`hr0c>*z0MJ zhS5p?{IR#16OgKJ4i8n|IKb6>KhUZv@s&;UFdQU{_JvK{xtpZFk08eiyLmT? zBI@B8gW`3&_Nyd*Q*++2JL1n3zy3^NRQ;ZlfrpzGm&SusIhGVb2- z%6a1t42hun$mHcL$uH4SUa|IiNxARU?1Y!%hHaS z0I8v4u^-b}1`z$9yA!;LEXmh=Xfgf~C@inxHYR%0PgFr5MO4<;{bfpN?^~+w{gB#m zXyYSF1iFT{6IH_umkYUujj7$4(LLC|h8S7krsJs1c*PAL$Oz9_Y(BESF-u%Ji-wR^q*f<$=D~`cL=oc}YZ4$|ZtiRc|DofD{K~5B;R< zk^F9bMi-4JHP@7Rw&UeqZ>lKfpxe*L6;%O34qW-p-4Igr(;Zb~f?X~+%SG}|!sa+{ zNS{l(9N80sS-aqo_IyDK4IEUYEz{3aVZNsnnp!~QwdY{vt8rhr*MIomz~Y{*Hun7- zzR(q*DYu`LZqV89-PHueOMcnk>YQMtnMPigh~ZzBNucZqt0hj_XgizCL8Z{&TlO&I zcika2f+03&&MPU(Wg0eh1W8!>Ya-_4L=>u7{!;YZnZR4$PH!yz4BxxGU8MF_i}*L0 zzc3;#zcx_Be{p6#ff?zFea~uW=7#_KRo25kV8x(XcSFS|!Jda*g-;W9Rl2o3HXXle z#tc5&3V8Bw;G^YYop2H2lpE+win@C}F=%)CWCWE@`Ag*TJ8Dn{k3vKau%zX>-G z*9`UOc-t~Z_-H&XO-7H!s$?pxJ2&!=FxwOPu9|or^6gQhi0hqBAQhtEy-~*j5gCOI zpi(c|AF3X!#r3?OMOBn7+jQ);*zrcBlc*CgBvST6L2Q+J^(*lxDokTzr5r^FGkuO5 zdW@A#(5#39Zpa5Z37Pff*XcEj@#&d2p4w;?)q!NGHPpSri+?NEa%aYh>QB~C(csk} zWO6YyAUXPwrhpjc*!?Z=EhDSLpF~He9>b^!>eW8>pr_>Y!&elw^YNvgD9f`K^R0jg z(n^>o>y9gwM{F(ei;8f~@aZbq>2v?>J+fHMikQg)-&bJ3Ew^Re5?qjAzHsG|w=b`P z=*C_RXN3p(jh)p0kV877$#&GrN2w_G0DJOD&b(lxtlqI}vpxc0f;}`&P~RHfw9Q(_ zCv)wBxN;&J^o|Mz>-A5O-x9Dr%|R7NeP{4Eqpo96%mX5~S7}cA)Bvsoa_rP9Xqo?I z8KBNX)0;(T}wq-D2p`icsvFiIB1 z{Z+slPK;BA)vUz%z22x^Gh<_`+8xz5q?buJGpG@lX%sm$7?_PN2b&Co_+;PHn-U(6 z;U$~YbmBY$Gt?(8h>lXC$abyDAm7y-Z-Y>nt*O9t>`}{XtlZuazd1HWqoBC`UJ0ElQEsw*2*0Y7$zl6T4@y2>PZB_C~fgRW&{s zmaM*fdYLPlc!nTc`hg5iPWSHK+HSpSo6ei>3u!s7s_b$(9j3~PCe^lc08GR5fQSsy z%F`&=f4FB|2;+@doe^!vKPtQ(V7Eno{=sNqFAdLp@l4;D=*M3waJweauLh}mg)9p| zlg(1w9H_?}300rX3>F&^uazL+98Y3>!vr|u7BDD+Ycv{!JoQa4Vv2`$hs~#yEU?y@ z%rCQ2q)>Jx+K45y8xJ{;hp*m~JdM)#m|qMh(PS{3rKx^D zt-CJMBT$z)PGb{ZxBv@XFDL=G;T9rvIPF0SZ`Xsp_XqyP_b}4A?!-p_KkZz3I8<#L z9}%X7-Xtl@ypg5CQ1oGJNm=toj4U(57>Th&mJySsc(sQyNK|5~!Mqe2+aN}k36UW* z`k1j*vWzlj_|B-WtMA|U`o90Z^Ut}?ea`iqbDrgXe$R8?zu)0Z=S7J72IcRd_{~z> z7bm=6ItNDx1KKF!u?J(8_eW8YwbIa<-V?|CKTVgz8{P1AIfCboW?4f#hdt<_O}!RS z1G~>R@}gfd)tYAonNwkQD88kfA+%Y#kBeIZZLcGGR4~X)`&-JP`#;2TtNFgpJwXQC zSF+W9rn7m`XO0*%0bvE>KK{3uPmZQ<>*h+}9SJQnM=WF8@2W*yxBKfJ-M0Q#kz<35 z|AEjA#0ab*hfpTudEO5CHqp;1$E?!BYz-O6(!y2uIPi_?n2dZcnt3Gf1Kg4!re~#Q zS}S2t!X1!43fzB52`Tw^pF+$@u~4%Q2m6~-CTU4#mZAch~?G;HF;Sm;7# z^9b|?Gt~)L2sETL=fXiVV3-UWwY(cF4A$&I($8rR?cmJuXlL^m87w#WrR9$?R+%P` zlo!jXWis@eC~W3*RJ~rs0JgdXU-RzBc5n~xF_^7C4qExH;W=8Igr+Q(}>);vJOcJwk4N_5$ zO&`C5dGz|PwH2-ni$936S7q9z26ZV3P?f}UBtFulP{#Qf&~v;)y`@~|-ghdbe?OBS=zBF=sqT%YAJM-!7!P&q#HU5jCRD%$1TE^`yUO$#DEx`;8dZQvaBg zKY*(gL|Zd=&GH|H%vrZFW=iWayr-wsyqNfsfwNDv1+1!JfqQW#QIV8chJ#AxuR6|b5m*(wuC@F9T2SFD8sc=(jrz|!_83;0L;#8XcKOK_>wvZ5T8 zZX#K3U@}{^v|@q0=ge(RY)Q?28K0`WAWj#mwj`f`iqG7BK!J5vS}h@X8A7Z|(@t4z zavK-7CvwO7Q*@Pgzi`9t4ie`88(QnnciIOxs8*qQa$+RZRlxq|PkTUvZ}3+AD%^DI z(ln@bBt&PeLo1K-yT%>@b9h>_m%lPc=9ejVX9iyDQC^7b7{HM$`czn_irfAB?*xQ9 zSJ&G9-NVZOLJ1T}l|np)bogucM#mH$gs&b>$ftQg zT_?1Vn>%6DDI@=kQTw$0fo!5|u?KcH)cI#2$pCX<$%3lYt$I<`ZsHs##8c5p#CG|D zg9(+|*$re7)l~;!sDzIf&P6S@zC_RL%op$c?I#oiz>GUel@I&WnB_d89X*aZ$b3(S zk!Kgp1+LaA23xaagc9p0ojN@KFCYle&lHK z`Hee2mB?4uiMhuA>@HhG)j+KcWgEYDp8v&FCtEseok2Cgic=bnd^Yvv8d6BIV&dJZ zrI+V8Z>jDHK@a2m7PW;$j)`=*nm69 zo628TXJ{?Eu53haAI&Xs0YA;)o;knMwepPISqU+7weIvn2eW&F)v;-$Qz41Zdom<` zDGSKYRP7$17{EM?dRBCvD*V@Tl}9&Jdh*!?ZP zO?G!w3w`9D>TBew&--r!G5MDsptmrvo~PmbC3!nlKy62p=tAjeQH7MTZ5n*qg*2y@ zLOHE0)7<%T$3evG}cVpJ#9XRJ*$o;0b zy176q{EtPzVtkvJ$Xf^=*bLn#k_v_zu%mK14}%pt?PN1D;OHFo=|-zxWY19NX5yj( zhct#d#^_`dd(ATYpY*%X``N0J-pAtzs+T_3i7iv^P zFD$sPsJIf9J5zbQWtJnEn^e-FFzg;$SgD>$+OD$G0>LIUci5gz%i?>Q{)MQ4k1xom0dUz3l>DYefWY zP@Xp%YCIL+wK*P4Uss*{?k39NbR%)}U?U!#C+F*%blJM0PyOG5Fl4+j8Z!9)e(lE? zmw<>TG%_F<;VZzdhSQXNA~yEEu}}?Nms4E#H)*13f*th(E)T6C1q-&L+rVa6K*D9s z*g?oix@=*!(75Bhp11kl#*=3dzKRMXMaQ6-xpEmqFP&TPJkJ(#mHJMstts`P>qt2u zs<05WN6;h+3*Gdyp2I|o<|B=$3`aqT_+qL#y^EYExi+09_0SiWU7zN$R67cxdOpje z%PN6iV5yACY}E1KjeU+DFtb~))0staYWejM-IV8QN|2U!IqsBbukzSkwJT z-;b#LMXwE0dMD680yMf!xXgWJ4hAKEX}?G@*r01eaq1NTr3mM( zoK)VuQ#g_Fd90{L!#d1nquOA4ca9J2E0^E?LP_mN%rRtwr zRo@2G>yP(=K+vtimjIU_kiF=SXbuR}3yAUv!$2TV!{Prw`d_YrW@Y@?6(7NeK%-sh zYqa^{&5=@o04*JWJ6R&&W(2SDo>a3Z@AbvV7I^+MdEnMMpL)xS13um{BPU7+6#$b^ zB@ZQzz|Fq(hc4~cR|HIB!lXVB9MHuB6#)<|O9bbZ5__Ukx_R8#7r9cz0POKSz-;Yz zRH^@Wc++_QvE_X8Er34EFwiZ5V{~0p?{A#n$hNFWi>;>KoH~bQ3rn)GI(e-0C@S$^ D8Eg{S literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0001.html b/docs/obs_3rd_party/java_sdk/obs_21_0001.html new file mode 100644 index 000000000..942475794 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0001.html @@ -0,0 +1,15 @@ + + +

SDK Download and Installation

+

Downloading OBS SDK for Java

  • Latest version of OBS Java SDK: Download
+
+

Compiling the Java Source Code

You can download the source code of SDK for Java and compile the source code to create a JAR package. Before using this method, ensure that the Java and Maven environments are correctly configured and can be used properly.

+
  1. Download the source code by referring to Downloading OBS SDK for Java and decompress it.
  2. Go to the directory where the source code is decompressed using commands.
  3. Run the following command:

    Linux:
    mvn clean package -Dmaven.test.skip=true -f pom-java.xml 
    +
    +
    Windows:
    mvn clean package "-Dmaven.test.skip=true" -f pom-java.xml
    +
    +

  4. Find the generated JAR package in the target subdirectory of the decompressed directory.
  5. Save the JAR package to the dependency path of the local project.
+
+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0002.html b/docs/obs_3rd_party/java_sdk/obs_21_0002.html new file mode 100644 index 000000000..1a566a32a --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0002.html @@ -0,0 +1,689 @@ + + +

API Overview

+

Bucket APIs

Table 1 lists the bucket-related APIs.

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 Bucket APIs

API

+

Method

+

Function

+

Creating a Bucket

+

obsClient.createBucket(CreateBucketRequest request)

+

Creates a bucket and configures the storage class, region, and ACL for the bucket.

+

Obtaining a Bucket List

+

obsClient.listBuckets(ListBucketsRequest request)

+

Lists all buckets that meet the specified conditions under the current account and returns them in alphabetical order.

+

Deleting a Bucket

+

obsClient.deleteBucket(String bucketName)

+

Deletes an empty bucket (the name of a deleted bucket can be reused at least 30 minutes after the deletion).

+

Checking Whether a Bucket Exists

+

obsClient.headBucket(String bucketName)

+

Checks whether a bucket exists (HTTP status code 200 indicates the bucket exists, while 404 indicates it does not).

+

Obtaining Bucket Metadata

+

obsClient.getBucketMetadata(BucketMetadataInfoRequest request)

+

Returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.

+

Setting a Bucket ACL

+

obsClient.setBucketAcl(String bucketName,AccessControlList acl)

+

Sets an ACL for a bucket.

+

Obtaining a Bucket ACL

+

obsClient.getBucketAcl(String bucketName)

+

Returns the ACL of a bucket.

+

Configuring a Bucket Policy

+

obsClient.setBucketPolicy(String bucketName, String policy)

+

Sets a bucket policy.

+

Obtaining the Policy of a Bucket

+

obsClient.getBucketPolicy(String bucketName)

+

Returns a bucket policy.

+

Deleting a Bucket Policy

+

obsClient.deleteBucketPolicy(String bucketName)

+

Deletes a bucket policy (204 No Content is returned if the policy is deleted successfully or actually does not exist).

+

Obtaining the Region of a Bucket

+

obsClient.getBucketLocation(String bucketName)

+

Returns the region where the bucket is created.

+

Obtaining Storage Information of a Bucket

+

obsClient.getBucketStorageInfo(String bucketName)

+

Returns the storage information about a bucket, including the storage usage and the object count in the bucket.

+

Configuring a Storage Quota

+

obsClient.setBucketQuota(String bucketName, BucketQuota bucketQuota)

+

Sets a limit on the capacity of a bucket.

+

Obtaining a Bucket Storage Quota

+

obsClient.getBucketQuota(String bucketName)

+

Returns the quota of a bucket (0 indicates there is no upper limit to the capacity of the bucket).

+

Configuring a Storage Class for a Bucket

+

obsClient.setBucketStoragePolicy(String bucketName, BucketStoragePolicyConfiguration bucketStorage)

+

Specifies the storage class for a bucket (after the bucket storage class is configured, if you do not specifically configure the storage class for objects in that bucket, those objects will inherit the storage class of the bucket by default).

+

Obtaining the Storage Class of a Bucket

+

obsClient.getBucketStoragePolicy(String bucketName)

+

Returns the storage class of a bucket.

+

Configuring an Inventory Rule

+

obsClient.setInventoryConfiguration(SetInventoryConfigurationRequest request)

+

Configures an inventory rule for a bucket (you can specify the object attributes to include in inventories, such as the object version, size, storage class, tag, encryption status, and last modification).

+

Obtaining an Inventory Rule

+

obsClient.getInventoryConfiguration(GetInventoryConfigurationRequest request)

+

Returns a bucket inventory rule specified by the rule ID.

+

Listing Inventory Rules

+

obsClient.listInventoryConfiguration(ListInventoryConfigurationRequest request)

+

Returns all inventory rules of a bucket in a single response.

+

Deleting an Inventory Rule

+

obsClient.deleteInventoryConfiguration(DeleteInventoryConfigurationRequest request)

+

Deletes a bucket inventory rule specified by the rule ID.

+
+
+

Object APIs

Table 2lists object-related APIs.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 Object APIs

API

+

Method

+

Function

+

Uploading an Object - Streaming

+

obsClient.putObject(PutObjectRequest request)

+

Uploads local files of any type that are smaller than 5 GB to a bucket in streaming mode.

+

Uploading an Object - File-Based

+

obsClient.putObject(PutObjectRequest request)

+

Uploads local files of any type to a bucket over the Internet.

+

Obtaining the Upload Progress

+

PutObjectRequest.setProgressListener(ProgressListener progressListener)

+

Returns the progress of uploading an object.

+

Creating a Folder

+

obsClient.putObject(PutObjectRequest request)

+

Creates a folder in a bucket to categorize the data.

+

Configuring Object Metadata

+

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

+

Sets object attributes (such as the size, MIME type, MD5 value, storage class, or user-defined metadata) when uploading an object in streaming, file-based, or multipart mode, or when copying an object.

+

Initiating a Multipart Upload

+

obsClient.initiateMultipartUpload(InitiateMultipartUploadRequest request)

+

Initiates a multipart upload and returns a globally unique upload ID.

+

Uploading a Part

+

obsClient.uploadPart(UploadPartRequest request)

+

Uploads parts to the bucket based on the upload ID returned by the preceding API.

+

Assembling Parts

+

obsClient.completeMultipartUpload(CompleteMultipartUploadRequest request)

+

Completes a multipart upload based on the multipart upload ID and information about the uploaded parts (including PartNumber and ETag).

+

Aborting a Multipart Upload

+

obsClient.abortMultipartUpload(AbortMultipartUploadRequest request)

+

Aborts a multipart upload specified by the upload ID in a bucket.

+

Listing Uploaded Parts

+

obsClient.listParts(ListPartsRequest request)

+

Returns the uploaded parts in a bucket based on the specified multipart upload ID.

+

Listing Multipart Uploads

+

obsClient.listMultipartUploads(ListMultipartUploadsRequest request)

+

Lists ongoing multipart uploads.

+

Configuring Lifecycle Rules

+

obsClient.putObject(PutObjectRequest request)

+

Configures a lifecycle rule for objects to periodically delete objects in the bucket or transition object storage classes (the object expiration time set using this API takes precedence over that set in a bucket lifecycle rule).

+

Uploading an Object - Append

+

obsClient.appendObject(AppendObjectRequest request)

+

Appends content to an existing object.

+

Uploading an Object - Resumable

+

obsClient.uploadFile(UploadFileRequest request)

+

Provides the resumable function based on the API for multipart uploads to better respond to network disconnections or program crashes.

+

Uploading an Object - Browser-Based

+

obsClient.createPostSignature(PostSignatureRequest request)

+

Uploads an object up to 5 GB in size to a bucket in the HTML form.

+

Downloading an Object - Streaming

+

obsClient.getObject(GetObjectRequest request)

+

Downloads an object from OBS to a local directory or memory (the returned results contain the object name, attributes, input stream, and bucket information).

+

Downloading an Object - Range-Based

+

obsClient.getObject(GetObjectRequest request)

+

Downloads the partial data of an object.

+

Obtaining the Download Progress

+

GetObjectRequest.setProgressListener(ProgressListener progressListener)

+

Returns the progress of downloading an object.

+

Downloading an Object - Conditional

+

obsClient.getObject(GetObjectRequest request)

+

Returns the objects that meet one or more specified conditions.

+

Rewriting Response Headers

+

obsClient.getObject(GetObjectRequest request)

+

Rewrites the following HTTP/HTTPS response headers when downloading an object: Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition, and Content-Encoding.

+

Obtaining User-defined Metadata

+

obsClient.getObject(GetObjectRequest request)

+

Returns the user-defined object metadata after the object is successfully downloaded.

+

Restoring a Cold Object

+

obsClient.restoreObject(RestoreObjectRequest request)

+

Restores and downloads a Cold object.

+

Downloading an Object - Resumable

+

obsClient.downloadFile(DownloadFileRequest request)

+

Adds the resumable function to the partial download API.

+

Configuring Object Metadata

+

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

+

Configures the object metadata.

+

Obtaining Object Metadata

+

obsClient.getObjectMetadata(GetObjectMetadataRequest request)

+

Returns the object metadata.

+

Configuring an Object ACL

+

obsClient.setObjectAcl(SetObjectAclRequest request)

+

Sets an ACL for an object when uploading the object or modifies the ACL of an existing object by calling an ACL API.

+

Obtaining an Object ACL

+

obsClient.getObjectAcl(GetObjectAclRequest request)

+

Obtains the ACL of an object in a specified bucket.

+

Listing Objects

+

obsClient.listObjects(ListObjectsRequest request)

+

Lists some or all objects in a bucket based on the specified prefix, object count, and start position and returns the objects in alphabetical order.

+

Deleting an Object

+

obsClient.deleteObject(DeleteObjectRequest request)

+

Deletes an object from a bucket.

+

Batch Deleting Objects

+

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

+

Deletes objects from a bucket in a batch.

+

(Deleted objects cannot be restored.)

+

Copying an Object

+

obsClient.copyObject(CopyObjectRequest request)

+

Creates a copy up to 5 GB for an object.

+

Copying an Object - Multipart

+

obsClient.copyPart(CopyPartRequest request)

+

Copies parts to a specified bucket based on the multipart upload ID returned in initiating a multipart upload.

+

Checking Whether an Object Exists

+

doesObjectExist(final GetObjectMetadataRequest request)

+

Checks whether an object exists (HTTP status code 200 indicates the object exists, while 404 indicates the object or bucket does not exist).

+
+
+
+

Temporarily Authorized Access APIs

Table 3 lists the APIs related to temporarily authorized access.

+ +
+ + + + + + + + + +
Table 3 Temporarily Authorized Access APIs

API

+

Method

+

Function

+

Accessing OBS Using a Signed URL

+

obsClient.createTemporarySignature(TemporarySignatureRequest request)

+

Creates a signed URL and specifies the expiration time for the URL to grant visitors temporary access.

+

(To allow other users to perform a temporary operation such as upload, you need to generate a URL for the corresponding operation and offer that to users.)

+
+
+
+

Versioning APIs

Table 4 lists the APIs related to versioning.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 Versioning APIs

API

+

Method

+

Function

+

Configuring Versioning for a Bucket

+

obsClient.setBucketVersioning(final SetBucketVersioningRequest request)

+

Configures versioning for objects in a bucket.

+

Obtaining the Versioning Status of a Bucket

+

obsClient.getBucketVersioning(final BaseBucketRequest request)

+

Returns the versioning status of a bucket.

+

Obtaining an Object Version

+

obsClient.getObject(GetObjectRequest request)

+

Returns a specified object version.

+

Copying an Object Version

+

obsClient.copyObject(CopyObjectRequest request)

+

Creates a copy up to 5 GB for a versioned object.

+

Restoring a Specific Cold Object Version

+

obsClient.restoreObject(RestoreObjectRequest request)

+

Restores a Cold object version.

+

(To download a Cold object version, you need to restore it first.)

+

Listing Object Versions

+

obsClient.listVersions(ListVersionsRequest request)

+

Lists some or all object versions in a bucket based on the specified prefix, version count, and start position and returns the versions in alphabetical order.

+

Setting an ACL for an Object Version

+

obsClient.setObjectAcl(SetObjectAclRequest request)

+

Sets an ACL for an object version.

+

Obtaining the ACL of an Object Version

+

obsClient.getObjectAcl(GetObjectAclRequest request)

+

Returns the ACL of an object version.

+

Deleting an Object Version

+

obsClient.deleteObject(DeleteObjectRequest request)

+

Deletes the ACL of an object version.

+

Batch Deleting Object Versions

+

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

+

Deletes object versions from a bucket in a batch.

+

(Deleted object versions cannot be restored.)

+
+
+
+

Lifecycle Rule APIs

Table 5 lists the APIs related to lifecycle rules.

+ +
+ + + + + + + + + + + + + + + + + +
Table 5 Lifecycle Rule APIs

API

+

Method

+

Function

+

Setting Lifecycle Rules

+

obsClient.setBucketLifecycle(final SetBucketLifecycleRequest request)

+

Sets a lifecycle rule for a bucket to periodically delete objects in the bucket or transition object storage classes.

+

Obtaining Lifecycle Rules

+

obsClient.getBucketLifecycle(final BaseBucketRequest request)

+

Returns a lifecycle rule of a bucket.

+

Deleting Lifecycle Rules

+

obsClient.deleteBucketLifecycle(final BaseBucketRequest request)

+

Deletes a lifecycle rule of a bucket.

+
+
+
+

CORS rule APIs

Table 6 lists the APIs related to CORS rules.

+ +
+ + + + + + + + + + + + + + + + + +
Table 6 CORS rule APIs

API

+

Method

+

Function

+

Configuring a CORS Rule

+

obsclient.setBucketCors(final SetBucketCorsRequest request)

+

Sets a CORS rule for a bucket (the existing rules will be overwritten by the new ones).

+

Obtaining a CORS Rule

+

obsclient.getBucketCors(final BaseBucketRequest request)

+

Returns a CORS rule of a bucket.

+

Deleting a CORS Rule

+

obsclient.deleteBucketCors(final BaseBucketRequest request)

+

Deletes a CORS rule of a bucket.

+
+
+
+

Bucket Logging APIs

Table 7 lists the logging APIs.

+ +
+ + + + + + + + + + + + + +
Table 7 Bucket logging APIs

API

+

Method

+

Function

+

Configuring Logging for a Bucket

+

obsClient.setBucketLogging(final SetBucketLoggingRequest request)

+

Enables logging for a source bucket, specifies a target bucket for storing log files, and configures the name prefixes and access permissions for log files.

+

Obtaining the Logging Configuration of a Bucket

+

obsClient.getBucketLogging(final BaseBucketRequest request)

+

Returns the logging configuration of a bucket.

+
+
+
+

Static Website Hosting APIs

Table 8 lists the APIs related to static website hosting.

+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 8 Static website hosting APIs

API

+

Method

+

Function

+

Hosting Website Files in a Bucket

+
  1. obsClient.putObject(PutObjectRequest request)
  2. obsClient.setObjectAcl(SetObjectAclRequest acl)
+

Uploads the files of a static website to a specified bucket in OBS, configures the public read permission for the files, and enables static website hosting for the bucket.

+

Configuring Static Website Hosting

+

obsClient.setBucketWebsite(final SetBucketWebsiteRequest request)

+

Configures website hosting for a bucket.

+

Obtaining Static Website Hosting Configurations

+

obsClient.getBucketWebsite(final BaseBucketRequest request)

+

Returns the website configuration of a bucket.

+

Deleting Static Website Hosting Configurations

+

obsClient.deleteBucketWebsite(final BaseBucketRequest request)

+

Deletes the website configuration of a bucket.

+
+
+
+

Tagging APIs

Table 9 lists the APIs related to tagging.

+ +
+ + + + + + + + + + + + + + + + + +
Table 9 Tagging APIs

API

+

Method

+

Function

+

Configuring Tags for a Bucket

+

obsClient.setBucketTagging(final SetBucketTaggingRequest request)

+

Tags a bucket to facilitate CDR filtering and cost analysis.

+

Obtaining Bucket Tags

+

obsClient.getBucketTagging(final BaseBucketRequest request)

+

Returns the tags of a bucket.

+

Deleting Bucket Tags

+

obsClient.deleteBucketTagging(final BaseBucketRequest request)

+

Deletes the tags of a bucket.

+
+
+
+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0100.html b/docs/obs_3rd_party/java_sdk/obs_21_0100.html new file mode 100644 index 000000000..f1bf51505 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0100.html @@ -0,0 +1,663 @@ + + +

Getting Started

+

This section introduces how to use OBS SDK for Java to perform some basic actions, such as creating a bucket, and uploading, downloading, listing, and deleting objects.

+

Preparations

Ensure you have made the following preparations before using the SDK:

+
+
  1. Before You Start: Select a proper SDK version.
  2. Preparations: Prepare the service and development environments.
  3. SDK Download and Installation: Download and install the OBS SDK for Java.
+

Creating a Bucket

The example below shows how to create a bucket named examplebucket, and configure access, storage class, region, and redundancy type for the bucket. For more details about how to create a bucket, see Creating a Bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.AvailableZoneEnum;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.ObsBucket;
+import com.obs.services.model.StorageClassEnum;
+
+public class CreateBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        
+        try {
+            CreateBucketRequest request = new CreateBucketRequest();
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example bucket location
+            request.setBucketName(exampleBucket);
+            // Set the bucket ACL to Private (the default value).
+            request.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            // Set the bucket storage class to Standard.
+            request.setBucketStorageClass(StorageClassEnum.STANDARD);
+            request.setLocation(exampleLocation);
+            // Create a bucket.
+            ObsBucket bucket = obsClient.createBucket(request);
+            // The bucket is created.
+            System.out.println("CreateBucket successfully");
+            System.out.println("RequestId:"+bucket.getRequestId());
+
+
+        } catch (ObsException e) {
+            System.out.println("CreateBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CreateBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+
+        }
+    }
+}
+
+
+
+

Uploading an Object

The example below shows how to upload two local files localfile and localfile2 to the bucket examplebucket, and specify the names of the objects created as objectkey and objectkey2 respectively. For more details about uploading an object, see Object Upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload files.
+            // localfile indicates the path of the local file to be uploaded, in which the file name must be specified.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectkey");
+            request.setFile(new File("localfile"));
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Downloading an Object

The example below shows how to download the object objectname from the bucket examplebucket. For more details about downloading an object, see Object Download.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+public class GetObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Download the object using streaming.
+            ObsObject obsObject = obsClient.getObject("examplebucket", "objectname");
+            // Read the object content.
+            System.out.println("Object content:");
+            InputStream input = obsObject.getObjectContent();
+            byte[] b = new byte[1024];
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            int len;
+            while ((len = input.read(b)) != -1) {
+                bos.write(b, 0, len);
+            }
+            System.out.println("getObjectContent successfully");
+            System.out.println(new String(bos.toByteArray()));
+            bos.close();
+            input.close();
+        } catch (ObsException e) {
+            System.out.println("getObjectContent failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectContent failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Listing Objects

The example below shows how to list objects in the bucket examplebucket. For more details about object listing, see Listing Objects.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Listing objects.
+            ObjectListing result = obsClient.listObjects("examplebucket");
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Deleting an Object

The example below shows how to delete the object objectname from the bucket examplebucket. For more details about deleting an object, see Deleting an Object.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete the object.
+            obsClient.deleteObject("examplebucket", "objectname");
+            System.out.println("deleteObject successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Using an OBS Client

The example below shows how to use an ObsClient instance.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
// Make sure there is only one ObsClient instance in the whole project.
+// ObsClient is thread-safe and can be used in concurrency scenarios.
+ObsClient obsClient = null; 
+try
+{
+    String endPoint = "https://your-endpoint";
+    // Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+    // Obtain an AK/SK pair on the management console.
+    String ak = System.getenv("ACCESS_KEY_ID");
+    String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+    // Create an ObsClient instance.
+    obsClient = new ObsClient(ak, sk, endPoint);
+    // Call an API to perform an operation, for example, uploading an object.
+HeaderResponse response = obsClient.putObject("bucketname", "objectname", new File("localfile"));  // localfile indicates the path of the local file to be uploaded. Use the file path in your case.
+    System.out.println(response);
+}
+catch (ObsException e)
+{
+    System.out.println("HTTP Code: " + e.getResponseCode());
+    System.out.println("Error Code:" + e.getErrorCode());
+    System.out.println("Error Message: " + e.getErrorMessage());
+    
+    System.out.println("Request ID:" + e.getErrorRequestId());
+    System.out.println("Host ID:" + e.getErrorHostId());
+    Map<String, String> headers = e.getResponseHeaders();// Check all map entries and print all headers with errors reported.
+    if(headers != null){
+        for (Map.Entry<String, String> header : headers.entrySet()) {    
+            System.out.println(header.getKey()+":"+header.getValue());    
+        }
+    }
+    e.printStackTrace();
+}finally{
+    // Close the ObsClient instance. If the instance is used globally, skip this step.
+    // After the ObsClient instance is closed by calling ObsClient.close, it cannot be used again.
+    if(obsClient != null){
+        try
+        {
+            // obsClient.close();
+        }
+        catch (IOException e)
+        {
+        } 
+    }
+}
+
+
+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0101.html b/docs/obs_3rd_party/java_sdk/obs_21_0101.html new file mode 100644 index 000000000..3b0c28215 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0101.html @@ -0,0 +1,10 @@ + + +

Before You Start

+

This section describes version compatibility and important notes about Object Storage Service (OBS) SDK for Java.

+

Compatibility

  • Recommended JDK versions: JDK 8 or later
  • Third-party dependencies: This version is not completely compatible with earlier versions (2.1.x). OkHttp 3 should be used to replace HttpClient4.x.
  • Namespace: This version is compatible with earlier versions (2.1.x). All external APIs are contained in the com.obs.services, com.obs.services.model, and com.obs.services.exception packages.
  • API functions: This version is compatible with earlier versions (2.1.x).
  • The earlier 2.X versions are no longer maintained. You are advised to upgrade them to the latest version as soon as possible.
+
+

Important Notes

  • Make sure that you are familiar with OBS basic concepts in Help Center, such as buckets, objects, regions, and access keys (AKs/SKs).
  • You can learn about how to call an API through the OBS SDK for Java by referring to Using an OBS Client.
  • After an API is called using an instance of ObsClient, if no exception is thrown, the return value is valid. If an exception is thrown, the operation fails. For details about errors, see SDK Exceptions.
  • After an API is successfully called using an instance of ObsClient, a class or sub-class instance of HeaderResponse that contains response headers will be returned.
  • Some features are available only in some regions. If an API call returns the 405 HTTP status code, check whether the region supports this feature.
+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0102.html b/docs/obs_3rd_party/java_sdk/obs_21_0102.html new file mode 100644 index 000000000..bdd0b4dbc --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0102.html @@ -0,0 +1,19 @@ + + +

Preparations

+

Before using OBS SDK for Java to access OBS, you need to prepare the service and development environments. To prepare the service environment, you will need an account and access keys. Both of them are necessary for interaction between OBS SDK and OBS. To ensure successful SDK installation and SDK-based code development and running, you should also set up a local development environment, for example, installing dependencies and development tools.

+

Preparing Access Keys

Access keys consist of two parts: an access key ID (AK) and a secret access key (SK). OBS uses access keys to sign requests to make sure that only authorized accounts can access specified OBS resources. Programmatic access must be enabled for an IAM user before the IAM user can get access keys. Access keys are explained as follows:

+
  • One AK maps to only one user but one user can have multiple AKs. OBS authenticates users by their AKs.
  • An SK is required for accessing OBS. Authentication information is generated based on the SK and request headers. AKs and SKs are in one-to-one match.
+

Access keys are classified into permanent access keys (AK/SK) and temporary access keys (AK/SK and security token). Each user can create at most two permanent access keys. Temporary access keys must be used within a given validity period. Once expired, they must be requested again. For security purposes, you are advised to use temporary access keys to access OBS. If you want to use permanent access keys, periodically update them. The following describes how to obtain two types of access keys.

+
  • To get permanent access keys, do as follows:
    1. Log in to the management console.
    2. In the upper right corner, hover over the username and choose My Credentials.
    3. On the My Credentials page, click Access Keys in the navigation pane.
    4. On the Access Keys page, click Create Access Key.
    5. In the displayed dialog box, enter the login password and verification code.
      • If you have not bound an email address or a mobile number yet, only the login password is required.
      • If you have bound both an email address and a mobile number, you can use either of them for verification.
      +
      +
    6. Click OK.
    7. Click Download. The access key file is automatically saved to your browser's default download path.
    8. Open the downloaded credentials.csv file to obtain the access keys (AK and SK).
      • Each user can create a maximum of two valid access key pairs.
      • Keep AKs and SKs properly to prevent information leakage. If you click Cancel in the download dialog box, the access keys will not be downloaded and cannot be downloaded later. You can create a new AK/SK pair if needed.
      +
      +
    +
  • To get temporary access keys, refer to the following:

    Temporary access keys are issued by the system and are only valid for 15 minutes to 24 hours. Once expired, they must be requested again. They follow the principle of least privilege. When a temporary AK/SK pair is used for authentication, a security token must be used at the same time.

    +
+
+

Setting Up a Development Environment

+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0200.html b/docs/obs_3rd_party/java_sdk/obs_21_0200.html new file mode 100644 index 000000000..aeeede051 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0200.html @@ -0,0 +1,15 @@ + + +

Initialization

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0201.html b/docs/obs_3rd_party/java_sdk/obs_21_0201.html new file mode 100644 index 000000000..0da50bf16 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0201.html @@ -0,0 +1,65 @@ + + +

Overview

+

After the SDK is installed, you need to create and configure an OBS client and configure the logging for the SDK to complete the initialization.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 Initialization

Task

+

Sub-task

+

Mandatory (Yes/No)

+

Description

+

Creating and Configuring an OBS Client

+

Creating an OBS client

+

Yes

+

OBS clients offer a series of APIs for you to use OBS SDK for Java to interact with OBS. Before sending a request to OBS, you need to create and initialize an OBS client (an ObsClient instance).

+

Configuring access credentials

+

Yes

+

For security purposes, you need to configure access credentials for the client so that the server can verify the validity of requests.

+

Configuring the endpoint and other parameters

+

Yes for the endpoint; No for other parameters

+
  • To quickly create and retrieve your resources, you need to configure an endpoint for the client so that the server can know where to create or retrieve resources.
  • You can configure other parameters for the client based on your needs.
+

Configuring SDK Logging

+

Configuring a log level

+

No

+

OBS SDK for Java offers logging based on the open-source library of Apache Log4j 2. The Log4j 2 framework classifies log files into different levels based on their priorities. You can specify a log level to customize the log storage scope.

+

By default, OBS SDK for Java saves log files of the WARN and higher levels to local directories.

+

Configuring a storage path for log files

+

No

+

Configure a local path to store logs.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0202.html b/docs/obs_3rd_party/java_sdk/obs_21_0202.html new file mode 100644 index 000000000..5697e291b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0202.html @@ -0,0 +1,737 @@ + + +

Creating and Configuring an OBS Client

+

Scenarios

This section describes how to create and configure an OBS client. If you already have a client, skip this section and obtain the API details by referring to API Overview.

+
+

Prerequisites

Ensure you have completed the following preparations:

+
  1. Select a proper SDK version by referring to Before You Start.
  2. Prepare the service and development environments by referring to Preparations.
  3. Download and install the OBS SDK for Java by referring to SDK Download and Installation.
+
+

Important Notes

  • Make sure to configure the client at the time you create it. After the client is created, you will not be able to configure it.
  • If you use a temporary AK/SK pair, you can call ObsClient.refresh("yourAccessKey", "yourSecretKey", "yourSecurityToken") to refresh to keep the pair valid, without the need to create a new ObsClient instance.
  • You are advised to create an ObsClient instance at the initialization and use it for the whole project. Creating multiple clients affects high-concurrency performance.
  • ObsClient is thread-safe and can be used in concurrency scenarios.
  • If a client is closed by calling ObsClient.close, it cannot be used again. To ensure the whole project uses only one client, you are advised not to proactively close the client.
+
+

Overview

Figure 1 Creating and configuring a client
+

You can select a client class, a method of obtaining access credentials, and other parameters by referring to Figure 1.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 Creating and configuring an OBS client

Category

+

Option

+

Description

+

Sample Code

+

Client

+

Client that does not transparently transmit access credentials

+

If you want to configure access credentials only once and use them for all API calls, use ObsClient.

+

ObsClient

+

Client that transparently transmits access credentials

+

If you need to configure access credentials for each API call, use SecretFlexibleObsClient, which is inherited from ObsClient.

+

SecretFlexibleObsClient

+

Access credentials

+

Passing access credentials as parameters

+

Create an ObsClient instance and pass access credentials as parameters.

+
+

Obtaining access credentials from environment variables

+

Create an ObsClient instance and use EnvironmentVariableObsCredentialsProvider to obtain access credentials from environment variables.

+

+

EnvironmentVariableObsCredentialsProvider

+

Obtaining access credentials from an agency in ECS scenarios

+

Create an ObsClient instance and use EcsObsCredentialsProvider to automatically obtain temporary access credentials from the ECS. The access credentials are periodically updated automatically.

+
NOTICE:
  1. To use EcsObsCredentialsProvider, ensure that the application runs on an ECS that has an IAM agency with OBS permissions.
  2. Ensure that the server and the environment where the application is deployed have the same UTC time, or temporary access keys may fail to be updated in a timely manner.
+
+

EcsObsCredentialsProvider

+

Using a chain to search for access credentials

+

You can use this method to search for access keys in a chain in a predefined sequence. The first pair of access keys obtained is used to create an ObsClient instance.

+

By default, environment variables are checked first and then the ECS agencies are checked to obtain access credentials. You cannot customize the search method or sequence.

+

OBSCredentialsProviderChain

+

Other configurations

+

Configuring only the endpoint

+

Other than access credentials, only the endpoint is configured.

+

Configuring Only the Endpoint

+

Configuring the endpoint and other parameters

+

In addition to the endpoint, you need to configure the HTTP proxy, Socket timeout, and other parameters. You can use the ObsConfiguration class to configure the ObsClient instance. For details about the supported parameters, see Table 2.

+

ObsConfiguration

+
+
+
+

Code Examples

  • Using the client class that does not transparently transmit access credentials to directly configure access credentials and configuring the endpoint
    • Using permanent access keys (AKs/SKs)
       1
      + 2
      + 3
      + 4
      + 5
      + 6
      + 7
      + 8
      + 9
      +10
      +11
      +12
      +13
      // Enter the endpoint of the region where the bucket is located.
      +String endPoint = "https://your-endpoint";
      +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
      +// Obtain an AK/SK pair on the management console.
      +String ak = System.getenv("ACCESS_KEY_ID");
      +String sk = System.getenv("SECRET_ACCESS_KEY_ID");
      +// Create an ObsClient instance.
      +ObsClient obsClient = new ObsClient(ak, sk, endPoint);
      + 
      +// Use the instance to access OBS.
      +        
      +// Close the instance.
      +obsClient.close();
      +
      +
      +
    • Using temporary access credentials (AKs/SKs and security tokens)
       1
      + 2
      + 3
      + 4
      + 5
      + 6
      + 7
      + 8
      + 9
      +10
      +11
      +12
      +13
      +14
      +15
      // Enter the endpoint of the region where the bucket is located.
      +
      +String endPoint = "https://your-endpoint";
      +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
      +// Obtain an AK/SK pair on the management console.
      +String ak = System.getenv("ACCESS_KEY_ID");
      +String sk = System.getenv("SECRET_ACCESS_KEY_ID");
      +String securityToken = System.getenv("SECRET_TOKEN");
      +// Create an ObsClient instance.
      +ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
      + 
      +// Use the instance to access OBS.
      +        
      +// Close the instance.
      +obsClient.close();
      +
      +
      +
    • BasicObsCredentialsProvider
       1
      + 2
      + 3
      + 4
      + 5
      + 6
      + 7
      + 8
      + 9
      +10
      +11
      +12
      +13
      +14
      // Enter the endpoint of the region where the bucket is located.
      +
      +String endPoint = "https://your-endpoint";
      +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
      +// Obtain an AK/SK pair on the management console.
      +String ak = System.getenv("ACCESS_KEY_ID");
      +String sk = System.getenv("SECRET_ACCESS_KEY_ID");
      +// Create an ObsClient instance.
      +ObsClient obsClient = new ObsClient(new BasicObsCredentialsProvider(ak, sk), endPoint);
      + 
      +// Use the instance to access OBS.
      +        
      +// Close the instance.
      +obsClient.close();
      +
      +
      +
    +
  • Using the SecretFlexibleObsClient client class that transparently transmits access credentials
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    // Enter the endpoint of the region where the bucket is located.
    +
    +String endPoint = "https://your-endpoint";
    +// Create an instance of the ObsConfiguration class.
    +ObsConfiguration config = new ObsConfiguration();
    +config.setEndPoint(endPoint);
    +
    +// Create an instance of SecretFlexibleObsClient.
    +SecretFlexibleObsClient obsClient = new SecretFlexibleObsClient(config);
    +// Use the instance of SecretFlexibleObsClient to access OBS.
    +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
    +// Obtain an AK/SK pair on the management console.
    +String ak1 = System.getenv("ACCESS_KEY_ID");
    +String sk1 = System.getenv("SECRET_ACCESS_KEY_ID");
    +obsClient.listBuckets(ak1, sk1);
    +
    +String ak2 = System.getenv("ACCESS_KEY_ID");
    +String sk2 = System.getenv("SECRET_ACCESS_KEY_ID");
    +obsClient.listBuckets(ak2, sk2);
    +
    +// Close the instance.
    +obsClient.close();
    +
    +
    +
  • Using EnvironmentVariableObsCredentialsProvider to obtain access credentials from environment variables
    In this method, you need to define OBS_ACCESS_KEY_ID and OBS_SECRET_ACCESS_KEY in the environment variables to represent the permanent AK and SK respectively.
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    // Enter the endpoint of the region where the bucket is located.
    +
    +String endPoint = "https://your-endpoint";
    +// Create an ObsClient instance.
    +ObsClient obsClient = new ObsClient(new EnvironmentVariableObsCredentialsProvider(), endPoint);
    + 
    +// Use the instance to access OBS.
    +        
    +// Close the instance.
    +obsClient.close();
    +
    +
    +
    +
  • Using EcsObsCredentialsProvider to obtain access credentials from an agency in the ECS scenarios
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    // Enter the endpoint of the region where the bucket is located.
    +
    +String endPoint = "https://your-endpoint";
    +// Create an ObsClient instance.
    +ObsClient obsClient = new ObsClient(new EcsObsCredentialsProvider(), endPoint);
    + 
    +// Use the instance to access OBS.
    +        
    +// Close the instance.
    +obsClient.close();
    +
    +
    +
  • Using OBSCredentialsProviderChain to obtain access credentials from a chain
     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    // Enter the endpoint of the region where the bucket is located.
    +
    +String endPoint = "https://your-endpoint";
    +// Create an ObsClient instance.
    +ObsClient obsClient = new ObsClient(new OBSCredentialsProviderChain(), endPoint);
    + 
    +// Use the instance to access OBS.
    +        
    +// Close the instance.
    +obsClient.close();
    +
    +
    +
  • Using ObsConfiguration to configure parameters for the client
    • KeyManagerFactory: By configuring KeyManagerFactory, you can save a certificate on your local PC and check whether the certificate returned by the server is correct.
       1
      + 2
      + 3
      + 4
      + 5
      + 6
      + 7
      + 8
      + 9
      +10
      +11
      +12
      +13
      +14
      +15
      +16
      +17
      +18
      +19
      +20
      +21
      +22
      +23
      +24
      +25
      +26
      +27
      +28
      +29
      +30
      +31
      +32
      // Enter the endpoint of the region where the bucket is located.
      +
      +String endPoint = "https://your-endpoint";
      +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
      +// Obtain an AK/SK pair on the management console.
      +String ak = System.getenv("ACCESS_KEY_ID");
      +String sk = System.getenv("SECRET_ACCESS_KEY_ID");
      +
      +String jksPassword = "you-jks-password";
      +String jksPath = "/path/to/your/keystore/file";
      +KeyStore ks = KeyStore.getInstance("JKS");
      +char[] passArray = jksPassword.toCharArray();
      +FileInputStream inputStream = new FileInputStream(jksPath);
      +ks.load(inputStream, passArray);
      +KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
      +kmf.init(ks, passArray);
      +
      +String trustJKSPassword = "you-trustJKS-password";
      +String trustJKSPath = "/path/to/your/trustKeyStore/file";
      +KeyStore trustKeyStore = KeyStore.getInstance("JKS");
      +char[] trustPassArray = trustJKSPassword.toCharArray();
      +FileInputStream trustInputStream = new FileInputStream(trustJKSPath);
      +trustKeyStore.load(trustInputStream, trustPassArray);
      +TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
      +tmf.init(trustKeyStore);
      +
      +ObsConfiguration config = new ObsConfiguration();
      +config.setEndPoint(endPoint);
      +config.setKeyManagerFactory(kmf);
      +config.setTrustManagerFactory(tmf);
      +
      +ObsClient obsClient = new ObsClient(ak, sk, config);
      +
      +
      +

      The local certificate must be stored as a .jks file. You can run the following command to call the Java keytool to convert a .cer certificate into a .jks one:

      +
      keytool -import -file your-cer-file.cer -keystore your-keystore-file.jks
      +
      +
    • HTTP proxy: After the HTTP proxy is configured, the SDK uses the proxy to access the server.
       1
      + 2
      + 3
      + 4
      + 5
      + 6
      + 7
      + 8
      + 9
      +10
      +11
      +12
      +13
      +14
      +15
      +16
      +17
      // Enter the endpoint of the region where the bucket is located.
      +
      +String endPoint = "https://your-endpoint";
      +// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
      +// Obtain an AK/SK pair on the management console.
      +String ak = System.getenv("ACCESS_KEY_ID");
      +String sk = System.getenv("SECRET_ACCESS_KEY_ID");
      +
      +// The URL cannot contain the protocol header http:// or https://.
      +String proxyUrl = "proxy.com";
      +int proxyPort = 8080;
      +String proxyUser = "userName";
      +String proxyPassword = "password";
      +ObsConfiguration config = new ObsConfiguration();
      +config.setEndPoint(endPoint);
      +config.setHttpProxy(proxyUrl, proxyPort, proxyUser, proxyPassword);
      +ObsClient obsClient = new ObsClient(ak, sk,config);
      +
      +
      +
    +
+
+

Configuring a User-Defined Domain Name to Access OBS

// Specify the user-defined domain name that has been configured on the console.
+String endPoint = "http://your-domain";
+// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+// Obtain an AK/SK pair on the management console.String ak = System.getenv("ACCESS_KEY_ID");
+String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+
+// Create an instance of the ObsConfiguration class.
+ObsConfiguration config = new ObsConfiguration();
+config.setEndPoint(endPoint);
+config.setCname(true);
+
+// Create an ObsClient instance.
+ObsClient obsClient = new ObsClient(ak, sk, config);
+
+// Create an instance of ObsClient using Provider.
+// ObsClient obsClient = new ObsClient(new EnvironmentVariableObsCredentialsProvider(), config);
+// ObsClient obsClient = new ObsClient(new EcsObsCredentialsProvider(), config);
+
+// Use the instance to access OBS.
+
+// Close the instance.
+obsClient.close();
+
+

ObsConfiguration Parameters

  • If the network bandwidth is sufficient, you can tune the socketWriteBufferSize, sockeReadBufferSize, readBufferSize, and writeBufferSize parameters to improve upload and download performance.
  • If the network condition is poor, you are advised to increase the values of connectionTimeout and socketTimeout.
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ObsConfiguration parameters

Parameter

+

Description

+

Method

+

Recommended Value

+

connectionTimeout

+

Explanation:

+

The amount of time to wait when initially establishing an HTTP/HTTPS connection before giving up and timing out.

+

Default value:

+

60000, in milliseconds.

+

ObsConfiguration.setConnectionTimeout

+

[10000, 60000]

+

socketTimeout

+

Explanation:

+

The amount of time to wait for data to be transferred by the socket layer before the transfer times out.

+

Default value:

+

60000, in milliseconds.

+

ObsConfiguration.setSocketTimeout

+

[10000, 60000]

+

idleConnectionTime

+

Explanation:

+

If the idle time of a connection exceeds the value of this parameter, the connection is closed. To ensure your services run smoothly, you are advised to set this parameter to a value less than or equal to 30000 ms.

+

Default value:

+

30000, in ms.

+

ObsConfiguration.setIdleConnectionTime

+

[0, 30000]

+

maxIdleConnections

+

Explanation:

+

The allowed maximum number of pooled idle connections.

+

Default value:

+

1000

+

ObsConfiguration.setMaxIdleConnections

+

Configure this parameter based on your needs.

+

maxConnections

+

Explanation:

+

The allowed maximum number of concurrent HTTP requests.

+

Default value:

+

1000

+

ObsConfiguration.setMaxConnections

+

Default

+

maxErrorRetry

+

Explanation:

+

The allowed maximum number of retry attempts for failed requests (for example, request exceptions, or 500 or 503 error responses from the server).

+

Restrictions:

+

This parameter is invalid if an exception occurs when the data stream of the object to upload or download is being processed.

+

Default value:

+

3

+

ObsConfiguration.setMaxErrorRetry

+

[0, 5]

+

endPoint

+

Explanation:

+

OBS server address. It consists of a protocol type, domain name, and port number, for example, https://your-endpoint:443. For security purposes, you are advised to use HTTPS.

+

Restrictions:

+

For DNS resolution and OBS reliability reasons, you are not allowed to specify an IP address for this parameter because this will lead to a path-style request being used, which is prohibited by OBS. You need to use a domain name to specify this parameter.

+

Default value:

+

None

+

ObsConfiguration.setEndPoint

+

Configure this parameter based on your needs.

+

httpProxy

+

Explanation:

+

HTTP proxy configuration.

+

Default value:

+

This parameter is left blank by default.

+

ObsConfiguration.setHttpProxy

+

Configure this parameter based on your needs.

+

validateCertificate

+

Explanation:

+

Whether to verify the server certificate.

+

Value range:

+
  • true: The server certificate is verified.
  • false: The server certificate is not verified.
+

Default value:

+

false

+

ObsConfiguration.setValidateCertificate

+

Configure this parameter based on your needs.

+

verifyResponseContentType

+

Explanation:

+

Whether to verify the ContentType header in the response.

+

Value range:

+
  • true: The ContentType header is verified.
  • false: The ContentType header is not verified.
+

Default value:

+

true

+

ObsConfiguration.setVerifyResponseContentType

+

Default

+

readBufferSize

+

Explanation:

+

Size of the buffer used for downloading objects from socket streams. The value -1 indicates that no buffer is configured.

+

Default value:

+

-1, in bytes.

+

ObsConfiguration.setReadBufferSize

+

Configure this parameter based on your needs.

+

writeBufferSize

+

Explanation:

+

Size of the buffer used for uploading objects to socket streams. The value -1 indicates that no buffer is configured.

+

Default value:

+

-1, in bytes.

+

ObsConfiguration.setWriteBufferSize

+

Configure this parameter based on your needs.

+

socketWriteBufferSize

+

Explanation:

+

Size of the sending buffer of the socket. This parameter corresponds to java.net.SocketOptions.SO_SNDBUF.

+

Default value:

+

-1, in bytes, indicating that this parameter is not configured.

+

ObsConfiguration.setSocketWriteBufferSize

+

Default

+

socketReadBufferSize

+

Explanation:

+

Size of the receiving buffer of the socket. This parameter corresponds to java.net.SocketOptions.SO_RCVBUF.

+

Default value:

+

-1, in bytes, indicating that this parameter is not configured.

+

ObsConfiguration.setSocketReadBufferSize

+

Default

+

keyManagerFactory

+

Explanation:

+

Factory used for generating javax.net.ssl.KeyManager.

+

Default value:

+

This parameter is left blank by default.

+

ObsConfiguration.setKeyManagerFactory

+

Configure this parameter based on your needs.

+

trustManagerFactory

+

Explanation:

+

Factory used for generating javax.net.ssl.TrustManager.

+

Default value:

+

This parameter is left blank by default.

+

ObsConfiguration.setTrustManagerFactory

+

Configure this parameter based on your needs.

+

isStrictHostnameVerification

+

Explanation:

+

Whether to strictly verify the server-side host name. If this parameter is set to true, javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier needs to be used to create an object as an implementation of javax.net.ssl.HostnameVerifier to verify the host name.

+

Value range:

+
  • true: The host name of the server is strictly verified.
  • false: The host name of the server is not strictly verified.
+

Default value:

+

false

+

ObsConfiguration.setIsStrictHostnameVerification

+

Configure this parameter based on your needs.

+

keepAlive

+

Explanation:

+

Whether to use persistent connections to access OBS.

+

Value range:

+
  • true: Persistent connections are used.
  • false: Persistent connections are not used.
+

Default value:

+

true

+

ObsConfiguration.setKeepAlive

+

Configure this parameter based on your needs.

+

cname

+

Explanation:

+

Whether to use a user-defined domain name to access OBS.

+

Value range:

+
  • true: A user-defined domain name is used.
  • false: A user-defined domain name is not used.
+

Default value:

+

false

+

ObsConfiguration.setCname

+

Configure this parameter based on your needs.

+

sslProvider

+

Explanation:

+

Provider of the SSLContext.

+

Default value:

+

The SSLContext provided by the JDK is used.

+

ObsConfiguration.setSslProvider

+

Configure this parameter based on your needs.

+

httpProtocolType

+

Explanation:

+

HTTP protocol type used for accessing the OBS server.

+

Default value:

+

HTTP1.1

+
NOTE:

If the value of endPoint does not contain any protocol, HTTPS is used by default.

+
+

ObsConfiguration.setHttpProtocolType

+

Configure this parameter based on your needs.

+

httpDispatcher

+

Explanation:

+

User-defined dispatcher.

+

Default value:

+

None

+

ObsConfiguration.setHttpDispatcher

+

Configure this parameter based on your needs.

+

secureRandom

+

Explanation:

+

User-defined random number generator.

+

Default value:

+

new SecureRandom()

+
NOTE:
  • On some platforms, the implementation of new SecureRandom() may be insecure. For security purposes, you are advised to use ObsConfiguration.setSecureRandom() to get a SecureRandom instance from a true random seed.
  • If an operating system does not have sufficient entropy to generate random numbers (for example, when the system is just started), SecureRandom that generates true random numbers may be blocked until there is enough entropy available. To address this issue, you can take measures (such as using haveged in Linux) to supplement entropy.
+
+

ObsConfiguration.setSecureRandom

+

Configure this parameter based on your needs.

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0204.html b/docs/obs_3rd_party/java_sdk/obs_21_0204.html new file mode 100644 index 000000000..9fde6bbed --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0204.html @@ -0,0 +1,15 @@ + + +

Configuring SDK Logging

+

OBS SDK for Java offers logging based on the open-source Apache Log4j 2 library. By default, the SDK stores WARN log files to the directory specified by the JDK system variable user.dir. You can modify the log configuration file based on your needs.

+

Procedure

  1. Obtain the file log4j2.xml from the OBS SDK for Java package.
  2. Modify the log level and storage path in the file as required.
  3. Save the file to the classpath root directory, or call Log4j2Configurator.setLogConfig to specify the storage path of the file.
+
+
  • For details about SDK logging, see Log Analysis.
  • You can modify the log4j2.xml file to configure access permissions for log files.
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0300.html b/docs/obs_3rd_party/java_sdk/obs_21_0300.html new file mode 100644 index 000000000..9f1c7a39d --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0300.html @@ -0,0 +1,15 @@ + + +

Fault Locating

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0301.html b/docs/obs_3rd_party/java_sdk/obs_21_0301.html new file mode 100644 index 000000000..0bf385fa4 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0301.html @@ -0,0 +1,63 @@ + + +

Methods

+

If problems occur when using the OBS Java SDK, you can perform the following steps to analyze and locate the problems.

+
  1. Make sure that of OBS Java SDK is used.
  2. Make sure that the logging function of OBS Java SDK is enabled. For details about how to enable the function, see the Log Analysis section. The recommended log level is WARN.
  3. Make sure that the program code of the OBS Java SDK complies with Using an OBS Client. All call exceptions of ObsClient APIs are processed as required. The following is a code example of uploading an object:

     1
    + 2
    + 3
    + 4
    + 5
    + 6
    + 7
    + 8
    + 9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    ObsClient obsClient = null; 
    +try
    +{
    +    String endPoint = "https://your-endpoint";
    +    // Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
    +    // Obtain an AK/SK pair on the management console.
    +    String ak = System.getenv("ACCESS_KEY_ID");
    +    String sk = System.getenv("SECRET_ACCESS_KEY_ID");
    +
    +    obsClient = new ObsClient(ak, sk, endPoint);
    +    HeaderResponse response = obsClient.putObject("bucketname", "objectname", new ByteArrayInputStream("Hello OBS".getBytes())); 
    +    // (Optional) If a call is successful, record the HTTP status code and request ID returned by the server.
    +    System.out.println(response.getStatusCode());
    +    System.out.println(response.getRequestId());
    +}
    +catch (ObsException e)
    +{
    +    // Recommended: When an exception occurs, record the HTTP status code, server-side error code, and request ID returned by the server.
    +    System.out.println("HTTP Code: " + e.getResponseCode());
    +    System.out.println("Error Code:" + e.getErrorCode());
    +    System.out.println("Request ID:" + e.getErrorRequestId());
    +    // Recommended: When an exception occurs, record the stack information.
    +    e.printStackTrace(System.out);
    +}
    +
    +
    +

    You can click here to view the details about ObsException.

    +
    +

  4. If an exception occurs when an ObsClient API is called, obtain the HTTP status code and OBS server-side error code from ObsException or log file, and compare them to locate the exception cause.
  5. If the exception cause cannot be found in step 4, obtain the request ID returned by the OBS server from ObsException or log file and contact the OBS server O&M team to locate the cause.
  6. If the request ID is unable to be obtained, collect the stack information of ObsException and contact the OBS client O&M team to locate the cause.
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0302.html b/docs/obs_3rd_party/java_sdk/obs_21_0302.html new file mode 100644 index 000000000..fd72ee83a --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0302.html @@ -0,0 +1,196 @@ + + +

Other Notable Issues

+

SignatureDoesNotMatch

1
+2
HTTP Code: 403
+Error Code: SignatureDoesNotMatch
+
+
+

Possible causes are as follows:

+
  1. The SK input into ObsClient initialization is incorrect. Solution: Make sure that the SK is correct.
  2. This problem is caused by a bug in the OBS Java SDK of an earlier version. Solution: Upgrade the SDK to the latest version.
  3. OBS Java SDK 2.1.x versions are incompatible with the dependent library Apache HttpClient. Solution: Use httpcore-4.4.4 and httpclient-4.5.3.
+
+

MethodNotAllowed

1
+2
HTTP Code: 405
+Error Code: MethodNotAllowed
+
+
+
+

This error occurs because a feature on which the ObsClient API depends has not been rolled out on the requested OBS server. Contact the OBS O&M team for further confirmation.

+

BucketAlreadyOwnedByYou

1
+2
HTTP Code: 409
+Error Code: BucketAlreadyOwnedByYou
+
+
+
+

In OBS, a bucket name must be globally unique. Solution: If this error occurs when the ObsClient.createBucket is called, check whether the bucket exists. You can use either of the following methods to check whether a bucket exists:

+

Method 1 (recommended): Call ObsClient.listBuckets to query the list of all buckets that you own and check whether the bucket exists.

+

Method 2: Call ObsClient.headBucket to check whether the bucket exists.

+

ObsClient.headBucket can query only buckets in the current region, while ObsClient.listBuckets can query buckets in all regions.

+
+

BucketAlreadyExists

1
+2
HTTP Code: 409
+Error Code: BucketAlreadyExists
+
+
+
+

In OBS, a bucket name must be globally unique. Solution: If this error occurs when ObsClient.createBucket is called, it indicates that the bucket has been created by another user. Use a different bucket name and try again.

+

Connection Timeout

1
+2
+3
+4
HTTP Code: 408
+Caused by: java.net.ConnectException: Connection timed out: connect
+	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
+	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
+
+
+

Possible causes are as follows:

+
  1. The endpoint input during ObsClient initialization is incorrect. Solution: Make sure that the endpoint is correct.
  2. The network between the OBS client and OBS server is abnormal. Solution: Check the health status of the network.
  3. The OBS domain name resolved by DNS is inaccessible. Solution: Contact the OBS O&M team.
+
+

Read/Write Timeout

1
+2
+3
+4
+5
+6
HTTP Code: 408
+Error Code:RequestTimeOut
+Caused by: java.net.SocketTimeoutException: timeout
+	at okio.Okio$4.newTimeoutException(Okio.java:232)
+	at okio.AsyncTimeout.exit(AsyncTimeout.java:285)
+	at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)
+
+
+

Possible causes are as follows:

+
  1. The network latency between the OBS client and OBS server is too long. Solution: Check the health status of the network.
  2. The network between the OBS client and OBS server is abnormal. Solution: Check the health status of the network.
+
+

Abnormal Returned Value -1

1
HTTP Code: -1
+
+
+
+

Possible causes are as follows:

+
  1. The OBS Java SDK of an earlier version is used and a connection timeout or read/write timeout occurs. Solution: See the solutions for connection timeout and read/write timeout.
  2. This is a bug in earlier versions of OBS Java SDK. Solution: Use .
  3. The server returns an exception. Solution: Obtain the request ID returned by OBS server from the log and contact the OBS O&M team.
+

Unable to Obtain Error Codes from ObsException

Possible causes are as follows:

+
  1. An error is reported when ObsClient.getBucketMetadata or ObsClient.getObjectMetadata is called. In this scenario, the server does not return an error code because the request method used in the background is HEAD. Solution: Call ObsException.getResponseCode to obtain the HTTP status code to analyze the possible cause. For example, 403 indicates that the user does not have the access permission, and 404 indicates that the bucket or object does not exist. If the cause cannot be located, obtain the request ID returned by the OBS server from ObsException and contact the OBS O&M team.
  2. The endpoint passed during ObsClient initialization cannot correspond to a valid IP address of the OBS server after DNS resolution. Solution: Check whether the endpoint is correct. If the endpoint is correct, contact the OBS O&M team.
+
+

UnknownHostException

1
+2
+3
+4
Caused by: java.net.UnknownHostException: bucketname.unknowndomain.com
+	at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
+	at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
+	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
+
+
+

Possible causes are as follows:

+
  1. The endpoint input during ObsClient initialization is incorrect. Solution: Make sure that the endpoint is correct.
  2. DNS cannot resolve the OBS domain name. Solution: Contact the OBS O&M team.
+
+

NullPointException

1
+2
+3
Exception in thread "main" java.lang.NullPointerException
+	at com.obs.services.internal.RestStorageService.isCname(RestStorageService.java:1213)
+	at com.obs.services.ObsClient.doActionWithResult(ObsClient.java:2805)
+
+
+
+

Possible causes are as follows:

+
  1. ObsClient.close is called to close ObsClient and then another ObsClient API is called. Solution: Call ObsClient.close to release resources only before exiting the application.
  2. This is a bug in earlier versions of OBS Java SDK. Solution: Use .
+

Connection Leakage

1
A connection to xxx was leaked. Did you forget to close a response body?
+
+
+
+

This error occurs when ObsClient.getObject is not properly closed after it is called to obtain the data stream of the object to be downloaded. To fix this error, call the ObsObject.getObjectContent.close method in the finally statement block to close the connection.

+

Problem in SDK Version Upgrade

The third-party dependency of the SDK of an earlier version (2.1.x) is not completely compatible with that of the new SDK (3.x). If a program startup error occurs after the earlier version is upgraded to the new version, refer to Resolving Dependency Missing or Conflicts to rectify the fault. If the fault persists, contact the OBS O&M team.

+
+

OkHttp Error After an SDK Upgrade

1
+2
+3
+4
+5
+6
Exception in thread "main" java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
+	at com.obs.services.internal.RestConnectionService.createRequestBuilder(RestConnectionService.java:157)
+	at com.obs.services.internal.RestConnectionService.setupConnection(RestConnectionService.java:148)
+	at com.obs.services.internal.RestConnectionService.setupConnection(RestConnectionService.java:124)
+	at com.obs.services.internal.RestStorageService.performRequest(RestStorageService.java:395)
+	at com.obs.services.internal.RestStorageService.performRequest(RestStorageService.java:388)
+
+
+
+

This error occurs because OkHttp of an earlier version was used after the SDK upgrade. To resolve this issue, upgrade OkHttp to a required version by referring to Resolving Dependency Missing or Conflicts.

+

StackOverflowError After an SDK Upgrade

1
+2
+3
+4
+5
+6
+7
+8
+9
Caused by: java.lang.StackOverflowError
+	at sun.misc.URLClassPath.getResource(URLClassPath.java:211) ~[?:1.8.0_91]
+	at java.net.URLClassLoader$1.run(URLClassLoader.java:365) ~[?:1.8.0_91]
+	at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[?:1.8.0_91]
+	at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_91]
+	at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[?:1.8.0_91]
+	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_91]
+	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_91]
+	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1806) 
+
+
+
+

Check the JVM parameter xss and set it to 1 MB. xss indicates the memory size allocated to each thread started by the JVM. By default, the value of xss is 256 KB for JDK 1.4 and 1 MB for JDK 1.5 or later.

+

SSL peer shut down incorrectly

 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
javax.net.ssl.SSLException: SSL peer shut down incorrectly
+	at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:596)
+	at sun.security.ssl.InputRecord.read(InputRecord.java:532)
+	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
+	at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:933)
+	at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
+	at obs.shaded.okio.Okio$2.read(Okio.java:140)
+	at obs.shaded.okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
+	at obs.shaded.okio.RealBufferedSource.read(RealBufferedSource.java:51)
+	at obs.shaded.okhttp3.internal.http1.Http1ExchangeCodec$AbstractSource.read(Http1ExchangeCodec.java:389)
+	at obs.shaded.okhttp3.internal.http1.Http1ExchangeCodec$FixedLengthSource.read(Http1ExchangeCodec.java:427)
+	at obs.shaded.okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.java:286)
+	at obs.shaded.okio.RealBufferedSource$1.read(RealBufferedSource.java:447)
+	at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
+	at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
+	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
+	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
+	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
+	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
+	at java.io.InputStreamReader.read(InputStreamReader.java:184)
+	at java.io.BufferedReader.fill(BufferedReader.java:161)
+	at java.io.BufferedReader.readLine(BufferedReader.java:324)
+	at java.io.BufferedReader.readLine(BufferedReader.java:389)
+
+
+
+

Do not read file streams by line during a download on the client. For details, see the demo for a streaming download.

+

Others

For details, see FAQs.

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0303.html b/docs/obs_3rd_party/java_sdk/obs_21_0303.html new file mode 100644 index 000000000..8bb216399 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0303.html @@ -0,0 +1,69 @@ + + +

Resolving Dependency Missing or Conflicts

+

Dependency missing and dependency conflict are commonly encountered in Java development or during SDK integration. If error message "ClassNotFoundException" or "NoClassDefFoundError" is reported during application compilation and running, check whether this is a dependency-triggered problem. If yes, perform the following steps to locate and rectify the fault.

+

Dependency Missing

The following table lists the third-party components (including their versions) that the latest SDK depends on.

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Dependency

+

Version

+

Description

+

okhttp

+

4.11.0

+

Used to send HTTP requests.

+

okio

+

3.5.0

+

Component of OkHttp

+

java-xmlbuilder

+

1.3

+

Used to construct and parse XML files.

+

jackson-core

+

2.13.3

+

Used to construct and parse JSON files.

+

jackson-databind

+

2.15.0

+

Component of jackson-core

+

jackson-annotations

+

2.13.3

+

Component of jackson-core

+
+
+

Dependency Conflict

If your project has multiple versions of OBS Java SDK packages or third-party dependencies, dependency conflicts may occur. If there are SDKs of earlier versions, delete them and use the latest version. If there are multiple versions of third-party dependencies, replace the conflict ones with the versions required by the SDK.

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0400.html b/docs/obs_3rd_party/java_sdk/obs_21_0400.html new file mode 100644 index 000000000..1622c88c2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0400.html @@ -0,0 +1,43 @@ + + +

Bucket Management

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0401.html b/docs/obs_3rd_party/java_sdk/obs_21_0401.html new file mode 100644 index 000000000..533e08206 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0401.html @@ -0,0 +1,925 @@ + + +

Creating a Bucket

+

Function

This API creates an OBS bucket. Buckets are containers for storing objects (files uploaded to OBS) in OBS.

+

When creating a bucket, you can also configure parameters such as the storage class, region, and access control list (ACL) as needed.

+
+

Restrictions

  • To create a bucket, you must have the obs:bucket:CreateBucket permission. IAM is recommended for granting permissions. For details, see .
  • A maximum of 100 buckets and parallel file systems in total can be created globally for an account. There is no limit on the number or size of objects stored in a bucket.
  • The created bucket name must be unique in OBS. If you repeatedly create buckets with the same name in the same region, an HTTP status code 200 will be returned. In other cases, creating a bucket with an existing bucket name will have an HTTP status code 409 returned, indicating that such a bucket already exists.
  • The name of a deleted bucket can be reused for another bucket or a parallel file system at least 30 minutes after the deletion.
+
+

Method

  • Method 1: Create a bucket with a specified name.

    createBucket(String bucketName)

    +
  • Method 2: Create a bucket with a specified name in a specified region.

    createBucket(String bucketName, String location)

    +
+
  • Method 3: Create a bucket with a specified name in a specified region.

    createBucket(ObsBucket bucket)

    +
+
  • Method 4: Create a bucket and configure access permissions, storage class, location, cluster type, bucket type (object bucket or parallel file system), enterprise project ID, and extension permissions for the bucket.

    createBucket(CreateBucketRequest request)

    +
+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

CreateBucketRequest

+

Yes

+

Explanation:

+

Request parameters for creating a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CreateBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

location

+

String

+

Yes if the region where the OBS service resides is not the default region

+

Explanation:

+

Region where a bucket will be located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 5 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Bucket storage class that can be specified at bucket creation.

+

Value range:

+

See Table 12.

+

Default value:

+

STANDARD

+

extensionPermissionMap

+

Map<ExtensionBucketPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionBucketPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

epid

+

String

+

No

+

Explanation:

+

Enterprise project ID that can be specified at bucket creation. If you have enabled Enterprise Project Management Service (EPS), you can obtain the project ID from the EPS console.

+

Restrictions:

+

The value of epid is a Universally Unique Identifier (UUID). epid is not required if you have not enabled EPS yet.

+

Example: 9892d768-2d13-450f-aac7-ed0e44c2585f

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ExtensionBucketPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants the READ permission to an account ID.

+

The account with the READ permission can list objects, multipart uploads, and object versions in the bucket you are creating, and can obtain bucket metadata.

+

GRANT_WRITE

+

Grants the WRITE permission to an account ID.

+

The account with the WRITE permission can create, delete, and overwrite objects in the bucket you are creating, and can initiate or abort multipart uploads, as well as upload, copy, and assemble parts.

+

GRANT_READ_ACP

+

Grants the READ_ACP permission to an account ID.

+

The account with the READ_ACP permission can read the ACL of the bucket you are creating.

+

GRANT_WRITE_ACP

+

Grants the WRITE_ACP permission to an account ID.

+

The account with the WRITE_ACP permission can modify the ACL of the bucket you are creating.

+

GRANT_FULL_CONTROL

+

Grants the FULL_CONTROL permission to an account ID.

+

The account with the FULL_CONTROL permission can perform any operation on the bucket you are creating.

+

GRANT_READ_DELIVERED

+

Grants the READ permission to an account ID. By default, this READ permission applies to all objects in the bucket.

+

GRANT_FULL_CONTROL_DELIVERED

+

Grants the FULL_CONTROL permission to an account ID. By default, this FULL_CONTROL permission applies to all objects in the bucket.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 6.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 8.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

For details, see Table 11.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 9.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

For details, see Table 10.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 10 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 12 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsBucket

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Bucket owner information. For details, see Table 6.

+

creationDate

+

java.util.Date

+

Explanation:

+

Time when the bucket was created.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket will be located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Bucket storage class that can be specified at bucket creation.

+

Value range:

+

See Table 12.

+

Default value:

+

STANDARD

+

acl

+

AccessControlList

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 5 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+
+

Code Example: Creating a Bucket with Complex Configurations

This example creates a bucket and configures its ACL, storage class, and region.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.AvailableZoneEnum;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.ObsBucket;
+import com.obs.services.model.StorageClassEnum;
+
+public class CreateBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        
+        try {
+            CreateBucketRequest request = new CreateBucketRequest();
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example bucket location
+            request.setBucketName(exampleBucket);
+            // Set the bucket ACL to Private (the default value).
+            request.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            // Set the bucket storage class to Standard.
+            request.setBucketStorageClass(StorageClassEnum.STANDARD);
+            request.setLocation(exampleLocation);
+            // Create a bucket.
+            ObsBucket bucket = obsClient.createBucket(request);
+            // The bucket is created.
+            System.out.println("CreateBucket successfully");
+            System.out.println("RequestId:"+bucket.getRequestId());
+
+
+        } catch (ObsException e) {
+            System.out.println("CreateBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CreateBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+
+        }
+    }
+}
+
+
+
+

Code Example: Creating a Bucket with Simple Configurations

This example creates a bucket and specifies its name and endpoint.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsBucket;
+
+public class CreateBucket002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Create a bucket.
+            ObsBucket bucket = obsClient.createBucket(exampleBucket);
+            System.out.println("CreateBucket successfully");
+            System.out.println("StatusCode: " + bucket.getStatusCode());
+            System.out.println("RequestId: " + bucket.getRequestId());
+        } catch (ObsException e) {
+            System.out.println("CreateBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CreateBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0402.html b/docs/obs_3rd_party/java_sdk/obs_21_0402.html new file mode 100644 index 000000000..d53b3796b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0402.html @@ -0,0 +1,726 @@ + + +

Obtaining a Bucket List

+

Function

OBS buckets are containers for storing objects you upload to OBS. This API returns a list of all buckets that meet the specified conditions in all regions of the current account. Returned buckets are listed in alphabetical order by bucket name.

+
+

Restrictions

  • To obtain a bucket list, you must have the obs:bucket:ListAllMyBuckets permission.
+
  • To query the bucket location when listing buckets, you need to set ListBucketsRequest.setQueryLocation to true.
+
+

Method

obsClient.listBuckets(ListBucketsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

ListBucketsRequest

+

Yes

+

Explanation:

+

Request parameters for listing buckets. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 ListBucketsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

queryLocation

+

boolean

+

No

+

Explanation:

+

Whether to query the bucket location

+

Value range:

+
  • true: The bucket location is queried.
  • false: The bucket location is not queried.
+

Default value:

+

false

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 ListBucketsResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

Default value:

+

None

+

buckets

+

List<ObsBucket>

+

Explanation:

+

Bucket list information. For details, see Table 13.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 5 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 8.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 9.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 10 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 12 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsBucket

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

creationDate

+

java.util.Date

+

Explanation:

+

Time when the bucket is created.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket is located

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Bucket storage class that can be specified at bucket creation.

+

Value range:

+

See Table 5.

+

Default value:

+

STANDARD

+

acl

+

AccessControlList

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 12 for the available options.
  • To use a user-defined ACL, see Table 6 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+
+

Code Examples

This example lists all buckets and queries the bucket regions.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ObsBucket;
+import java.util.List;
+public class ListBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List buckets.
+            ListBucketsRequest request = new ListBucketsRequest();
+            request.setQueryLocation(true);
+            List<ObsBucket> buckets = obsClient.listBuckets(request);
+            for (ObsBucket bucket : buckets) {
+                System.out.println("ListBuckets successfully");
+                System.out.println("BucketName:" + bucket.getBucketName());
+                System.out.println("CreationDate:" + bucket.getCreationDate());
+                System.out.println("Location:" + bucket.getLocation());
+            }
+        } catch (ObsException e) {
+            System.out.println("ListBuckets failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("ListBuckets failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0403.html b/docs/obs_3rd_party/java_sdk/obs_21_0403.html new file mode 100644 index 000000000..eadc71256 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0403.html @@ -0,0 +1,183 @@ + + +

Deleting a Bucket

+

Function

This API deletes an empty bucket. You can delete buckets you no longer use to free up space. The name of a deleted bucket can be reused for another bucket at least 30 minutes after the deletion.

+
+

Restrictions

  • Only empty buckets can be deleted. An empty bucket means that:
    • The bucket does not contain any object (including noncurrent versions and delete markers).
    • The bucket does not contain any fragments, which means that there are no multipart uploads that have not been completed in the bucket.
    +
  • To delete a bucket, you must be the bucket owner or have the required permission (obs:bucket:DeleteBucket in IAM or DeleteBucket in a bucket policy).
  • Only empty buckets (without objects and part fragments) can be deleted.
  • Bucket deletion is a non-idempotence operation and an error will be reported if the bucket you want to delete does not exist.
+
+

Method

obsClient.deleteBucket(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 2 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HeaderResponse;
+public class DeleteBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Delete the bucket.
+            HeaderResponse response = obsClient.deleteBucket(exampleBucket);
+            System.out.println("DeleteBucket successfully");
+            System.out.println("StatusCode:"+response.getStatusCode());
+            System.out.println("RequestId:"+response.getRequestId());
+        } catch (ObsException e) {
+            System.out.println("DeleteBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("DeleteBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0404.html b/docs/obs_3rd_party/java_sdk/obs_21_0404.html new file mode 100644 index 000000000..173b77b7c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0404.html @@ -0,0 +1,165 @@ + + +

Checking Whether a Bucket Exists

+

Function

This API checks whether a bucket exists. If an HTTP status code 200 is returned, the bucket exists. If 404 is returned, the bucket does not exist.

+
+

Restrictions

  • To check whether a bucket exists, you must be the bucket owner or have the required permission (obs:bucket:HeadBucket in IAM or HeadBucket in a bucket policy).
+
+

Method

obsClient.headBucket(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + +
Table 2 List of returned results

Type

+

Description

+

boolean

+

Explanation:

+

Whether the bucket exists

+

Value range:

+

true: The bucket exists.

+

false: The bucket does not exist.

+

Default value:

+

None

+
+
+
+

Code Examples

This example checks whether bucket examplebucket exists.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class HeadBucket {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Check whether the bucket exists.
+            boolean exists = obsClient.headBucket(exampleBucket);
+            System.out.println("HeadBucket successfully");
+            System.out.println(exists);
+        } catch (ObsException e) {
+            System.out.println("HeadBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code :" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("HeadBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0405.html b/docs/obs_3rd_party/java_sdk/obs_21_0405.html new file mode 100644 index 000000000..51e13b1ae --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0405.html @@ -0,0 +1,404 @@ + + +

Obtaining Bucket Metadata

+

Function

This API returns information about a bucket, including the storage class, region, CORS rules, and redundancy policy.

+
+

Restrictions

  • To obtain bucket metadata, you must be the bucket owner or have the required permission (obs:bucket:HeadBucket in IAM or HeadBucket in a bucket policy).
  • For details about values for methods such as BucketMetadataInfoResult.getAllowMethods, see the CORS configurations of the bucket.
+
+

Method

obsClient.getBucketMetadata(BucketMetadataInfoRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BucketMetadataInfoRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining bucket metadata. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 BucketMetadataInfoRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

origin

+

String

+

No

+

Explanation:

+

Origin of the cross-domain request specified by the preflight request. Generally, it is a domain name.

+

Restrictions:

+

You can configure one or more rules and use at most one wildcard character (*) in each rule. If you want to configure multiple rules, separate them using a line breaker.

+

Default value:

+

None

+

requestHeaders

+

List<String>

+

No

+

Explanation:

+

HTTP headers in a cross-origin request. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

You can enter multiple allowed headers, with one separated from another using a line break. Each header can contain one wildcard character (*) at most. Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 BucketMetadataInfoResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header. Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket is located.

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

obsVersion

+

String

+

Explanation:

+

OBS version of the bucket.

+

Value range:

+
  • 3.0 indicates the latest OBS version.
  • -- indicates any version earlier than 3.0.
+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Bucket storage class that can be specified at bucket creation.

+

Value range:

+

See Table 4.

+

Default value:

+

STANDARD

+

allowOrigin

+

String

+

Explanation:

+

If Origin in the request meets the CORS rules of the bucket, AllowedOrigin specified in the CORS rules is returned.

+

Restrictions:

+

You can configure one or more rules and use at most one wildcard character (*) in each rule. If you want to configure multiple rules, separate them using a line breaker.

+

Default value:

+

None

+

allowHeaders

+

List<String>

+

Explanation:

+

If RequestHeader in the request meets the CORS rules of the bucket, AllowedHeader specified in the CORS rules is returned.

+

Restrictions:

+

You can enter multiple allowed headers, with one separated from another using a line break. Each header can contain one wildcard character (*) at most. Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

allowMethods

+

List<String>

+

Explanation:

+

The allowed HTTP methods for a cross-origin request, indicating the operation types of buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

exposeHeaders

+

List<String>

+

Explanation:

+

The CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to the list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

maxAge

+

int

+

Explanation:

+

Time your client can cache the response for a cross-origin request

+

Restrictions:

+

Each CORS rule can contain only one maxAge.

+

Value range:

+

An integer greater than 0, in seconds

+

Default value:

+

100

+

epid

+

String

+

Explanation:

+

Enterprise project ID that can be specified at bucket creation. If you have enabled EPS, you can obtain the project ID from the EPS console.

+

Restrictions:

+

The value of Epid is a UUID. If the default enterprise project is used, 0 is passed here or Epid is not included. Epid is not required for those who have not enabled the EPS.

+

Example: 9892d768-2d13-450f-aac7-ed0e44c2585f

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 4 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+

Code Examples

This example obtains the metadata of bucket examplebucket. The origin of the cross-origin request is http://www.exampleorigin.com.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketMetadataInfoRequest;
+import com.obs.services.model.BucketMetadataInfoResult;
+public class GetBucketMetadata001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            //Example origin
+            String exampleOrigin = "http://www.exampleorigin.com";
+            BucketMetadataInfoRequest request = new BucketMetadataInfoRequest(exampleBucket);
+            // Specify setOrigin only when cross origin resource sharing (CORS) is used.
+            request.setOrigin(exampleOrigin);
+            // Obtain the bucket metadata.
+            BucketMetadataInfoResult result = obsClient.getBucketMetadata(request);
+            System.out.println("GetBucketMetadata successfully");
+            System.out.println("GetBucketType:" + result.getBucketType());
+            System.out.println("GetLocation:" + result.getLocation());
+            System.out.println("GetBucketStorageClass:" + result.getBucketStorageClass());
+            System.out.println("GetObsVersion:" + result.getObsVersion());
+            System.out.println("GetAllowOrigin:" + result.getAllowOrigin());
+            System.out.println("GetMaxAge:" + result.getMaxAge());
+            System.out.println("GetAllowHeaders:" + result.getAllowHeaders());
+            System.out.println("GetAllowMethods:" + result.getAllowMethods());
+            System.out.println("GetExposeHeaders:" + result.getExposeHeaders());
+        } catch (ObsException e) {
+            System.out.println("GetBucketMetadata failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketMetadata failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0406.html b/docs/obs_3rd_party/java_sdk/obs_21_0406.html new file mode 100644 index 000000000..2a2dc7fcc --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0406.html @@ -0,0 +1,927 @@ + + +

Setting a Bucket ACL

+

Function

Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over resources when a bucket or object is created. That is, the bucket creator has full control over the bucket, and the object uploader has full control over the object. Other accounts do not have the permissions to access resources. If resource owners want to grant other accounts the read and write permissions on resources, they can use ACLs. ACLs grant permissions to accounts. After an account is granted permissions, both the account and its IAM users can access the resources.

+

+
+

You can configure a bucket ACL by referring to Method.

+

Restrictions

  • A bucket can have up to 100 ACL rules.
  • To configure an ACL for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketAcl in IAM or PutBucketAcl in a bucket policy).
+
+

Method

  • Method 1: Set a pre-defined ACL when creating a bucket.
    obsBucket.setBucketName(exampleBucket);
    +// Set the bucket ACL to private read and write.
    +obsBucket.setAcl(AccessControlList.REST_CANNED_PRIVATE);
    +// Create a bucket.
    +obsClient.createBucket(obsBucket);
    +
  • Method 2: After the bucket is created, set a pre-defined ACL.
    // Set the bucket ACL to private read and write.
    +obsClient.setBucketAcl(String exampleBucket, AccessControlList.REST_CANNED_PRIVATE);
    +
+
  • Method 3: After the bucket is created, set a user-defined ACL.
    // Set a user-defined ACL for the bucket.
    +obsClient.setBucketAcl(String bucketName,AccessControlList acl);
    +
+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

acl

+

AccessControlList

+

Yes

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 2 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

Yes

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
Table 3 ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 6.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 7.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 8 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 10 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Setting a Pre-defined ACL When Creating a Bucket

This example configures a pre-defined ACL during the creation of bucket exampleBucket.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.ObsBucket;
+public class SetBucketAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            ObsBucket obsBucket = new ObsBucket();
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            obsBucket.setBucketName(exampleBucket);
+            // Set the bucket ACL to private read and write.
+            obsBucket.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            // Create a bucket.
+            obsClient.createBucket(obsBucket);
+            System.out.println("SetBucketAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Setting a Pre-defined ACL for an Existing Bucket

This example configures a pre-defined ACL for bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+public class SetBucketAcl002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Set the bucket ACL to private read and write.
+            obsClient.setBucketAcl(exampleBucket, AccessControlList.REST_CANNED_PRIVATE);
+            System.out.println("SetBucketAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Setting a User-defined ACL for an Existing Bucket

This example defines an ACL for the exampleBucket bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.CanonicalGrantee;
+import com.obs.services.model.GroupGrantee;
+import com.obs.services.model.Owner;
+import com.obs.services.model.Permission;
+public class SetBucketAcl003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+       
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example user ID
+            String exampleUserid = "userid";
+            // Example user ID
+            String exampleOwnerId = "ownerid";
+            AccessControlList acl = new AccessControlList();
+            Owner owner = new Owner();
+            owner.setId(exampleOwnerId);
+            acl.setOwner(owner);
+            // Grant the full control permission to a specified user.
+            acl.grantPermission(new CanonicalGrantee(exampleUserid), Permission.PERMISSION_FULL_CONTROL);
+            // Grant the read permission to all users.
+            acl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
+            // Set the bucket ACL.
+            obsClient.setBucketAcl(exampleBucket, acl);
+            System.out.println("SetBucketAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

This example directly configures an ACL for bucket exampleBucket and applies this ACL to the objects in the bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.CanonicalGrantee;
+import com.obs.services.model.GroupGrantee;
+import com.obs.services.model.Owner;
+import com.obs.services.model.Permission;
+public class SetBucketAcl004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+       
+        // Create an instance of ObsClient.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            //Example bucket name
+            String exampleBucket = "examplebucket";
+            //Example user ID
+            String exampleUserid = "userid";
+            //Example owner ID
+            String exampleOwnerId = "ownerid";
+            AccessControlList acl = new AccessControlList();
+            Owner owner = new Owner();
+            owner.setId(exampleOwnerId);
+            acl.setOwner(owner);
+            // Grant the full control permission to a specific user. The bucket ACL also applies to the objects in the bucket.
+            acl.grantPermission(new CanonicalGrantee(exampleUserid), Permission.PERMISSION_FULL_CONTROL,true);
+            // Grant the read permission to all users. The bucket ACL also applies to the objects in the bucket.
+            acl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ,true);
+            // Set the bucket ACL.
+            obsClient.setBucketAcl(exampleBucket, acl);
+            System.out.println("SetBucketAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketAcl failed");
+            // Print other error details.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0407.html b/docs/obs_3rd_party/java_sdk/obs_21_0407.html new file mode 100644 index 000000000..006f846e9 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0407.html @@ -0,0 +1,204 @@ + + +

Configuring a Bucket Policy

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs.

+

A bucket policy applies to both the bucket and objects therein. You can use a bucket policy to grant permissions for a bucket and objects therein to IAM users or other accounts. If you want IAM users to have different permissions for different buckets, you need to configure different bucket policies for those users.

+
+

Besides bucket ACLs, bucket owners can use bucket policies to centrally control access to buckets and objects in buckets.

+

You can call ObsClient.setBucketPolicy to configure a bucket policy.

+

Restrictions

  • Due to data caching, after a bucket policy is configured, it takes 5 minutes at most for the policy to take effect.
  • To configure a bucket policy, you must be the bucket owner or the bucket owner's IAM user with the required permission (obs:bucket:PutBucketPolicy in IAM or PutBucketPolicy in a bucket policy).
  • The latest policy configurations will overwrite the preceding configurations when you call the API for configuring a bucket policy. For example, if you have configured bucket policies A, B, C, and D and you want to add a new bucket policy E, you must add policy E to the file containing the existing four policies and then upload the file with all policies contained. Likewise, if you want to delete bucket policy D, you must remove it from the file containing policies A, B, C, and D, and then upload the file without policy D contained.
  • OBS returns 404 NoSuchBucketPolicy when you call this API in the following scenarios:
    • The specified bucket policy does not exist.
    • The standard policy of the specified bucket is set to Private and no advanced policies are configured.
    +
+
+

Method

obsClient.setBucketPolicy(String bucketName, String policy)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

policy

+

String

+

Yes

+

Explanation:

+

Policy information in JSON format

+

Restrictions:

+
  • The bucket name contained in the Resource parameter of the policy must be the same as the one specified for the current bucket policy.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 2 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a policy for bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class SetBucketPolicy001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example bucket policy
+            String examplePolicy =
+                    "{\"Statement\":[{\"Principal\":\"*\",\"Effect\":\"Allow\",\"Action\":\"ListBucket\",\"Resource\":\""
+                            + exampleBucket
+                            + "\"}]}";
+            obsClient.setBucketPolicy(exampleBucket, examplePolicy);
+            System.out.println("SetBucketAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0408.html b/docs/obs_3rd_party/java_sdk/obs_21_0408.html new file mode 100644 index 000000000..79d7fde86 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0408.html @@ -0,0 +1,190 @@ + + +

Obtaining the Region of a Bucket

+

Function

This API returns the region where a bucket is located.

+
+

Restrictions

  • To obtain the region of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketLocation in IAM or GetBucketLocation in a bucket policy).
  • When creating a bucket, you can specify its location. For details, see Creating a Bucket.
+
+

Method

obsClient.getBucketLocation(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 2 BucketLocationResponse

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket is located.

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+
+
+
+

Code Examples

This example returns the region where bucket exampleBucket locates.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class GetBucketLocation001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Obtain the bucket region.
+            String location = obsClient.getBucketLocation(exampleBucket);
+            System.out.println("GetBucketLocation successfully");
+            System.out.println("Location:" + location);
+        } catch (ObsException e) {
+            System.out.println("GetBucketLocation failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketLocation failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0409.html b/docs/obs_3rd_party/java_sdk/obs_21_0409.html new file mode 100644 index 000000000..4eef9a3ca --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0409.html @@ -0,0 +1,208 @@ + + +

Obtaining Storage Information of a Bucket

+

Function

This API returns the storage information of a bucket, including the number of objects and the space occupied by the objects in the bucket.

+

OBS measures bucket storage statistics in the background and does not update the storage information in real time. So, you are advised not to perform real-time verification on the storage information.

+
+
+

Restrictions

  • To obtain the storage information of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStorageInfo in IAM or GetBucketStorage in a bucket policy).
+
+

Method

obsClient.getBucketStorageInfo(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 BucketStorageInfo

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

size

+

long

+

Explanation:

+

Size of the space occupied by objects in the bucket.

+

Value range:

+

A non-negative integer, in bytes.

+

Default value:

+

None

+

objectNum

+

long

+

Explanation:

+

Number of objects in the bucket.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the storage information of bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketStorageInfo;
+public class GetBucketStorageInfo001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Obtain the bucket storage information.
+            BucketStorageInfo storageInfo = obsClient.getBucketStorageInfo(exampleBucket);
+            System.out.println("GetBucketStorageInfo successfully");
+            System.out.println("GetObjectNumber:" + storageInfo.getObjectNumber());
+            System.out.println("GetStorageSize:" + storageInfo.getSize() + " bytes");
+        } catch (ObsException e) {
+            System.out.println("GetBucketStorageInfo failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketStorageInfo failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0410.html b/docs/obs_3rd_party/java_sdk/obs_21_0410.html new file mode 100644 index 000000000..16d0347c1 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0410.html @@ -0,0 +1,227 @@ + + +

Configuring a Storage Quota

+

Function

A quota limits the maximum capacity allowed in a bucket. By default, there is no limit on the storage capacity of the entire OBS system or a single bucket, and any number of objects can be stored. You can set a storage quota to control the total size of objects that can be uploaded to the bucket. After the storage quota has been reached, object upload will fail.

+

A quota limit does not apply to the objects uploaded before the quota is configured. If the specified quota is already smaller than the total size of existing objects in the bucket, the existing objects in the bucket will not be deleted, but no more object can be uploaded to the bucket later. In this case, to upload new objects, you must delete some of the existing objects to make the used space below the quota limit.

+
+

Restrictions

  • A bucket quota must be a non-negative integer in bytes.
  • OBS does not provide an API for deleting bucket storage quotas. You can set the bucket storage quota to 0 to cancel the limit.
  • To configure a storage quota for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketQuota in IAM or PutBucketQuota in a bucket policy).
+
+

Method

obsClient.setBucketQuota(String bucketName, BucketQuota bucketQuota)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

bucketQuota

+

BucketQuota

+

Yes

+

Explanation:

+

Bucket quota information

+

Restrictions:

+

See Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BucketQuota

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketQuota

+

long

+

Yes

+

Explanation:

+

Bucket quota.

+

Value range:

+

A non-negative integer, in bytes.

+

Default value:

+

0, indicating that there is no limit on the bucket quota.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a quota for bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketQuota;
+public class SetBucketQuota001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example bucket quota
+            long exampleBucketQuota = 1024 * 1024 * 100L;
+            // Set the bucket quota to 100 MB.
+            BucketQuota quota = new BucketQuota(exampleBucketQuota);
+            obsClient.setBucketQuota(exampleBucket, quota);
+            System.out.println("SetBucketQuota successfully");
+        } catch (ObsException e) {
+            System.out.println("SetBucketQuota failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("SetBucketQuota failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0411.html b/docs/obs_3rd_party/java_sdk/obs_21_0411.html new file mode 100644 index 000000000..a04dca167 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0411.html @@ -0,0 +1,309 @@ + + +

Configuring a Storage Class for a Bucket

+

Function

This API configures a storage class for a bucket. If you do not specify a storage class when uploading or copying an object, or initiating a multipart upload, the object inherits the bucket's storage class.

+
+

The following table lists the three available storage classes.

+ +
+ + + + + + + + + +

Storage Class

+

Description

+

Value in OBS Java SDK

+

Standard

+

Features low access latency and high throughput and is used for storing massive, frequently accessed (multiple times a month) or small objects (< 1 MB) requiring quick response.

+

StorageClassEnum.STANDARD

+
+
+

Restrictions

  • To configure a storage class for a bucket, you must be the bucket owner or have the required permission (obs:PutBucketStoragePolicy in IAM or PutBucketStoragePolicy in a bucket policy).
  • The bucket storage class is independent from the storage classes of objects in the bucket. When uploading an object, if you do not specify a storage class for the object, the object will use the same storage class that the bucket uses. However, after the object is uploaded, its storage class will not change as that of the bucket changes. Likewise, the storage class of the bucket will also not change if the storage class of any objects therein changes.
+
+

Method

obsClient.setBucketStoragePolicy(String bucketName, BucketStoragePolicyConfiguration bucketStorage)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 Request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

bucketStorage

+

BucketStoragePolicyConfiguration

+

(Inheriting HeaderResponse)

+

Yes

+

Explanation:

+

Storage class of the bucket.

+

Value range:

+

See Table 2.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 2 BucketStoragePolicyConfiguration

Parameter

+

Type

+

Description

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the bucket.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 4 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures a storage class for bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.AvailableZoneEnum;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.ObsBucket;
+import com.obs.services.model.StorageClassEnum;
+
+public class CreateBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        
+        try {
+            CreateBucketRequest request = new CreateBucketRequest();
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Example bucket location
+            request.setBucketName(exampleBucket);
+            // Set the bucket ACL to Private (the default value).
+            request.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            // Set the bucket storage class to Standard.
+            request.setBucketStorageClass(StorageClassEnum.STANDARD);
+            request.setLocation(exampleLocation);
+            // Create a bucket.
+            ObsBucket bucket = obsClient.createBucket(request);
+            // The bucket is created.
+            System.out.println("CreateBucket successfully");
+            System.out.println("RequestId:"+bucket.getRequestId());
+
+
+        } catch (ObsException e) {
+            System.out.println("CreateBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CreateBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+
+        }
+    }
+}
+
+
+
+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0412.html b/docs/obs_3rd_party/java_sdk/obs_21_0412.html new file mode 100644 index 000000000..d4716bfbf --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0412.html @@ -0,0 +1,457 @@ + + +

Obtaining a Bucket ACL

+

Function

Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over resources when a bucket or object is created. That is, the bucket creator has full control over the bucket, and the object uploader has full control over the object. Other accounts do not have the permissions to access resources. If resource owners want to grant other accounts the read and write permissions on resources, they can use ACLs. ACLs grant permissions to accounts. After an account is granted permissions, both the account and its IAM users can access the resources.

+

+

This API returns the ACL of a bucket.

+
+

Restrictions

  • To obtain the ACL of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketAcl in IAM or GetBucketAcl in a bucket policy).
+
+

Method

obsClient.getBucketAcl(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

Yes

+

Explanation:

+

Bucket owner information. For details, see Table 3.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 5.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 6.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 7 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Code Examples

This example obtains the ACL of the examplebucket bucket.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+public class GetBucketAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            //Obtain the bucket ACL.
+            AccessControlList acl = obsClient.getBucketAcl(exampleBucket);
+            System.out.println("GetBucketAcl successfully");
+            System.out.println(acl);
+        } catch (ObsException e) {
+            System.out.println("GetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0413.html b/docs/obs_3rd_party/java_sdk/obs_21_0413.html new file mode 100644 index 000000000..56f1750c2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0413.html @@ -0,0 +1,168 @@ + + +

Obtaining the Policy of a Bucket

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs. For more information, see .

+

This API returns the policy of a bucket.

+
+

Restrictions

  • OBS returns 404 NoSuchBucketPolicy when you call this API in the following scenarios:
    • The specified bucket policy does not exist.
    • The standard policy of the specified bucket is set to Private and no advanced policies are configured.
    +
  • To obtain the policy of a bucket, you must be the bucket owner or the bucket owner's IAM user with the required permission (obs:bucket:GetBucketPolicy in IAM or GetBucketPolicy in a bucket policy).
+
+

Method

obsClient.getBucketPolicy(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + +
Table 2 List of returned results

Parameter

+

Type

+

Description

+

policy

+

String

+

Explanation:

+

Policy information in JSON format

+

Restrictions:

+
  • The bucket name contained in the Resource parameter of the policy must be the same as the one specified for the current bucket policy.
+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the policy of bucket exampleBucket.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class GetBucketPolicy001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+     
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            String policy = obsClient.getBucketPolicy(exampleBucket);
+            System.out.println("\t" + policy);
+        } catch (ObsException e) {
+            System.out.println("GetBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0414.html b/docs/obs_3rd_party/java_sdk/obs_21_0414.html new file mode 100644 index 000000000..0fc7ff62f --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0414.html @@ -0,0 +1,175 @@ + + +

Deleting a Bucket Policy

+

Function

OBS provides access control over buckets. You can use an access policy to define whether a user can perform certain operations on a specific bucket. OBS access control can be implemented using IAM permissions, bucket policies, and ACLs. For more information, see .

+

You can call ObsClient.deleteBucketPolicy to delete the policy of a bucket. OBS returns 204 No Content if the deletion is successful or the requested bucket policy does not exist.

+
+

Restrictions

  • To delete the policy of a bucket, you must be the bucket owner or the bucket owner's IAM user with the required permission (obs:bucket:DeleteBucketPolicy in IAM or DeleteBucketPolicy in a bucket policy).
+
+

Method

obsClient.deleteBucketPolicy(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 2 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the policy of bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteBucketPolicy001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            obsClient.deleteBucketPolicy(exampleBucket);
+        } catch (ObsException e) {
+            System.out.println("DeleteBucketAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("DeleteBucketAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0415.html b/docs/obs_3rd_party/java_sdk/obs_21_0415.html new file mode 100644 index 000000000..37ed067f7 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0415.html @@ -0,0 +1,176 @@ + + +

Obtaining a Bucket Storage Quota

+

Function

This API returns the storage quota (upper limit of the storage capacity) of a bucket. If the quota is 0, there is no upper limit on the bucket capacity.

+
+

Restrictions

  • A bucket quota must be a non-negative integer in bytes.
  • A frozen bucket owner (due to account in arrears) is not allowed to query the bucket storage quota.
  • To obtain the storage quota of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketQuota in IAM or GetBucketQuota in a bucket policy).
+
+

Method

obsClient.getBucketQuota(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + +
Table 2 BucketQuota

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketQuota

+

long

+

Yes

+

Explanation:

+

Bucket quota.

+

Value range:

+

A non-negative integer, in bytes.

+

Default value:

+

0, indicating that there is no limit on the bucket quota.

+
+
+
+

Code Examples

This example returns the quota of bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketQuota;
+public class GetBucketQuota001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Obtain the bucket quota.
+            BucketQuota quota = obsClient.getBucketQuota(exampleBucket);
+            System.out.println("GetBucketQuota successfully");
+            System.out.println("GetBucketQuota:" + quota.getBucketQuota() + " bytes");
+        } catch (ObsException e) {
+            System.out.println("GetBucketQuota failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketQuota failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0416.html b/docs/obs_3rd_party/java_sdk/obs_21_0416.html new file mode 100644 index 000000000..a7ddec088 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0416.html @@ -0,0 +1,202 @@ + + +

Obtaining the Storage Class of a Bucket

+

Function

This API returns the storage class of a bucket.

+
+

Restrictions

  • To obtain a bucket's storage class, you must be the bucket owner or have the required permission (obs:bucket:GetBucketStoragePolicy in IAM or GetBucketStoragePolicy in a bucket policy).
+
+

Method

obsClient.getBucketStoragePolicy(String bucketName)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + +
Table 2 BucketStoragePolicyConfiguration

Parameter

+

Type

+

Description

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the bucket. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Code Examples

This example configures a storage class for bucket exampleBucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketStoragePolicyConfiguration;
+public class GetBucketStoragePolicy001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Example bucket name
+            String exampleBucket = "examplebucket";
+            // Obtain the bucket's storage class.
+            BucketStoragePolicyConfiguration storagePolicy = obsClient.getBucketStoragePolicy(exampleBucket);
+            System.out.println("GetBucketStoragePolicy successfully");
+            System.out.println("GetBucketStorageClass:" + storagePolicy.getBucketStorageClass());
+        } catch (ObsException e) {
+            System.out.println("GetBucketStoragePolicy failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetBucketStoragePolicy failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0417.html b/docs/obs_3rd_party/java_sdk/obs_21_0417.html new file mode 100644 index 000000000..1a2b8c4e9 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0417.html @@ -0,0 +1,405 @@ + + +

Configuring an Inventory Rule

+

Function

This API configures an inventory rule for the bucket. With this API, object information in a bucket (source) is regularly listed and saved as CSV files. These files are then stored in a specified bucket (destination). In this manner, you can easily manage objects in a bucket. A source bucket can also be the destination bucket. A bucket inventory file contains the following object-related information: object versions, sizes, storage classes, tags, encryption statuses, and last modification time.

+

You can encrypt bucket inventory files using SSE-KMS.

+
+

Restrictions

  • To configure an inventory rule for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketInventoryConfiguration in IAM or PutBucketInventoryConfiguration in a bucket policy).
  • Bucket versions
    • Bucket inventories can be generated only for OBS 3.0 buckets, but they can be stored in either OBS 3.0 or OBS 2.0.
    +
  • Number of bucket inventory rules
    • A bucket can have a maximum of 10 inventory rules.
    +
  • Source and destination buckets
    • The source bucket (for which a bucket inventory rule is configured) and the destination bucket (where the generated inventory files are stored) must belong to the same account.
    • The source bucket and the destination bucket must be in the same region.
    • Default encryption cannot be enabled for the destination bucket configured for storing inventory files.
    +
  • Functions
    • Inventory files must be in the CSV format.
    • OBS can generate inventory files for all objects in a bucket or a group of objects whose names begin with the same prefix.
    • If a bucket has multiple inventory rules, the filtering criteria in these rules must not overlap.
      • If a bucket already has an inventory rule for the entire bucket, new inventory rules that filter objects by prefixes cannot be created. If you need an inventory rule that covers only a subset of objects in the bucket, first delete the inventory rule configured for the entire bucket.
      • If an inventory rule that filters objects by a specified prefix already exists, you cannot create an inventory rule for the entire bucket. To create an inventory rule for the entire bucket, make sure that the bucket has no inventory rules that filter objects by specified prefixes.
      • If a bucket already has an inventory rule that filters objects by the object name prefix, such as ab, the filter of a new inventory rule cannot be any prefix that contains a, b, or ab. If you still need to create such rules, delete the inventory rule that uses the prefix ab first.
      +
    • Bucket inventory files only support SSE-KMS encryption.
    +
  • Permissions
    • Inventory files are uploaded to the destination bucket by an OBS system user. Therefore, you need to grant the system user the permission to write objects to the destination bucket.
    +
  • Others
    • The bucket inventory function is offered for free, but inventory files are billed for the storage they use.
    +
+
+

Method

obsClient.setInventoryConfiguration(SetInventoryConfigurationRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 SetInventoryConfigurationRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

inventoryConfiguration

+

InventoryConfiguration

+

Yes

+

Explanation:

+

Inventory configurations for a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 InventoryConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

configurationId

+

String

+

Yes

+

Explanation:

+

ID of a bucket inventory rule.

+

Restrictions:

+

The rule ID allows letters (a–z, A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

+

Value range:

+

The value can be up to 64 characters long.

+

Default value:

+

None

+

isEnabled

+

boolean

+

Yes

+

Explanation:

+

Whether the bucket inventory rule is enabled.

+

Value range:

+

true: The rule is enabled, and an inventory file is generated.

+

false: The rule is disabled. No inventory file is generated.

+

Default value:

+

true

+

objectPrefix

+

String

+

No

+

Explanation:

+

Used to filter objects. Only objects with the specified name prefix are included in the inventory.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

frequency

+

String

+

Yes

+

Explanation:

+

Intervals when inventories are generated. You can set this parameter to Daily or Weekly. An inventory is generated within one hour from when it is configured for the first time. Then it is generated at the specified intervals.

+

Value range:

+

Daily: Inventories are generated once a day.

+

Weekly: Inventories are generated once a week.

+

Default value:

+

None

+

inventoryFormat

+

String

+

Yes

+

Explanation:

+

Inventory file format. Only the CSV format is supported.

+

Value range:

+

CSV

+

Default value:

+

None

+

destinationBucket

+

String

+

Yes

+

Explanation:

+

Name of the bucket for storing inventories.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

inventoryPrefix

+

String

+

No

+

Explanation:

+

The prefix of the inventory file name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

If you do not specify this parameter, BucketInventory is used as the prefix by default.

+

includedObjectVersions

+

String

+

Yes

+

Explanation:

+

Whether versions of objects are included in an inventory.

+

Value range:

+
  • If this parameter is set to All, all the versions of objects are included in the inventory, and version-related fields are added to the inventory, including: VersionId, IsLatest, and DeleteMarker.
  • If this parameter is set to Current, the inventory only lists information about the current object version and does not include any version-related fields.
+

Default value:

+

None

+

optionalFields

+

ArrayList<String>

+

No

+

Explanation:

+

Additional object metadata fields that are contained in an inventory file.

+

Value range:

+

Size: Object size.

+

LastModifiedDate: Last time when the object was modified.

+

StorageClass: The storage class of the object.

+

ETag: The ETag value of the object.

+

IsMultipartUploaded: Whether the object was uploaded in a multipart upload.

+

ReplicationStatus: The cross-region replication status of the object.

+

EncryptionStatus: The encryption status of the object.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures an inventory for bucket example-bucket to list objects with the name prefix exampleObjectPrefix. The inventory files are stored in bucket example-target-bucket and the name prefix of the inventory files is exampleInventoryPrefix.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.inventory.InventoryConfiguration;
+import com.obs.services.model.inventory.SetInventoryConfigurationRequest;
+public class SetInventoryConfiguration001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the following parameters.
+            String exampleBucketName = "example-bucket";
+            String exampleTargetBucketName = "example-target-bucket";
+            String exampleConfigurationId = "exampleConfigId001";
+            String exampleInventoryPrefix = "exampleInventoryPrefix";
+            String exampleObjectPrefix = "exampleObjectPrefix";
+            // Set parameters for the inventory rule.
+            InventoryConfiguration exampleConfiguration = new InventoryConfiguration();
+            exampleConfiguration.setDestinationBucket(exampleTargetBucketName);
+            exampleConfiguration.setConfigurationId(exampleConfigurationId);
+            exampleConfiguration.setInventoryFormat(InventoryConfiguration.InventoryFormatOptions.CSV);
+            exampleConfiguration.setFrequency(InventoryConfiguration.FrequencyOptions.DAILY);
+            exampleConfiguration.setEnabled(true);
+            exampleConfiguration.setIncludedObjectVersions(
+                    InventoryConfiguration.IncludedObjectVersionsOptions.CURRENT);
+            exampleConfiguration.setInventoryPrefix(exampleInventoryPrefix);
+            exampleConfiguration.setObjectPrefix(exampleObjectPrefix);
+            // Set additional metadata fields that will be contained in the inventory file.
+            exampleConfiguration
+                    .getOptionalFields()
+                    .add(InventoryConfiguration.OptionalFieldOptions.IS_MULTIPART_UPLOADED);
+            exampleConfiguration.getOptionalFields().add(InventoryConfiguration.OptionalFieldOptions.ETAG);
+            exampleConfiguration
+                    .getOptionalFields()
+                    .add(InventoryConfiguration.OptionalFieldOptions.REPLICATION_STATUS);
+            SetInventoryConfigurationRequest request =
+                    new SetInventoryConfigurationRequest(exampleBucketName, exampleConfiguration);
+            // Set the inventory rule.
+            HeaderResponse response = obsClient.setInventoryConfiguration(request);
+            System.out.println("SetInventoryConfiguration succeeded");
+            System.out.println("HTTP Code: " + response.getStatusCode());
+        } catch (ObsException e) {
+            System.out.println("SetInventoryConfiguration failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("SetInventoryConfiguration failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0418.html b/docs/obs_3rd_party/java_sdk/obs_21_0418.html new file mode 100644 index 000000000..84e8aab29 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0418.html @@ -0,0 +1,389 @@ + + +

Obtaining an Inventory Rule

+

Function

This API returns an inventory rule (identified by configurationId) for the bucket.

+
+

Restrictions

  • To obtain a bucket inventory rule, you must be the bucket owner or have the required permission (obs:bucket:GetInventoryConfiguration in IAM or GetInventoryConfiguration in a bucket policy).
+
+

Method

obsClient.getInventoryConfiguration(GetInventoryConfigurationRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 GetInventoryConfigurationRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

configurationId

+

String

+

Yes

+

Explanation:

+

ID of the inventory rule.

+

Restrictions:

+

The ID can be up to 64 bytes long and allows letters (a–z, A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 2 GetInventoryConfigurationResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

inventoryConfiguration

+

InventoryConfiguration

+

Explanation:

+

Bucket inventory configurations. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 InventoryConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

configurationId

+

String

+

Yes

+

Explanation:

+

ID of a bucket inventory rule.

+

Restrictions:

+

The rule ID allows letters (a–z, A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

+

Value range:

+

The value can be up to 64 characters long.

+

Default value:

+

None

+

isEnabled

+

boolean

+

Yes

+

Explanation:

+

Whether the bucket inventory rule is enabled.

+

Value range:

+

true: The rule is enabled, and an inventory file is generated.

+

false: The rule is disabled. No inventory file is generated.

+

Default value:

+

true

+

objectPrefix

+

String

+

No

+

Explanation:

+

Used to filter objects. Only objects with the specified name prefix are included in the inventory.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

frequency

+

String

+

Yes

+

Explanation:

+

Intervals when inventories are generated. You can set this parameter to Daily or Weekly. An inventory is generated within one hour from when it is configured for the first time. Then it is generated at the specified intervals.

+

Value range:

+

Daily: Inventories are generated once a day.

+

Weekly: Inventories are generated once a week.

+

Default value:

+

None

+

inventoryFormat

+

String

+

Yes

+

Explanation:

+

Inventory file format. Only the CSV format is supported.

+

Value range:

+

CSV

+

Default value:

+

None

+

destinationBucket

+

String

+

Yes

+

Explanation:

+

Name of the bucket for storing inventories.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

inventoryPrefix

+

String

+

No

+

Explanation:

+

The prefix of the inventory file name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

If you do not specify this parameter, BucketInventory is used as the prefix by default.

+

includedObjectVersions

+

String

+

Yes

+

Explanation:

+

Whether versions of objects are included in an inventory.

+

Value range:

+
  • If this parameter is set to All, all the versions of objects are included in the inventory, and version-related fields are added to the inventory, including: VersionId, IsLatest, and DeleteMarker.
  • If this parameter is set to Current, the inventory only lists information about the current object version and does not include any version-related fields.
+

Default value:

+

None

+

optionalFields

+

ArrayList<String>

+

No

+

Explanation:

+

Additional object metadata fields that are contained in an inventory file.

+

Value range:

+

Size: Object size.

+

LastModifiedDate: Last time when the object was modified.

+

StorageClass: The storage class of the object.

+

ETag: The ETag value of the object.

+

IsMultipartUploaded: Whether the object was uploaded in a multipart upload.

+

ReplicationStatus: The cross-region replication status of the object.

+

EncryptionStatus: The encryption status of the object.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the inventory rule whose ID is exampleConfigId001 for bucket example-bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.inventory.GetInventoryConfigurationRequest;
+import com.obs.services.model.inventory.GetInventoryConfigurationResult;
+import com.obs.services.model.inventory.InventoryConfiguration;
+public class GetInventoryConfiguration001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the following parameters.
+            String exampleBucketName = "example-bucket";
+            String exampleConfigurationId = "exampleConfigId001";
+            GetInventoryConfigurationRequest request =
+                    new GetInventoryConfigurationRequest(exampleBucketName, exampleConfigurationId);
+            // Obtain the inventory rule.
+            GetInventoryConfigurationResult result = obsClient.getInventoryConfiguration(request);
+            InventoryConfiguration inventoryConfiguration = result.getInventoryConfiguration();
+            // Print all parameters in the inventory rule.
+            System.out.println("ConfigurationId:" + inventoryConfiguration.getConfigurationId());
+            System.out.println("DestinationBucket:" + inventoryConfiguration.getDestinationBucket());
+            System.out.println("InventoryFormat:" + inventoryConfiguration.getInventoryFormat());
+            System.out.println("Enabled:" + inventoryConfiguration.getEnabled());
+            System.out.println("Frequency:" + inventoryConfiguration.getFrequency());
+            System.out.println("IncludedObjectVersions:" + inventoryConfiguration.getIncludedObjectVersions());
+            System.out.println("InventoryPrefix:" + inventoryConfiguration.getInventoryPrefix());
+            System.out.println("ObjectPrefix:" + inventoryConfiguration.getObjectPrefix());
+            System.out.println("OptionalFields:" + inventoryConfiguration.getOptionalFields());
+            // Print the HTTP status code.
+            System.out.println("HTTP Code: " + result.getStatusCode());
+            System.out.println("GetInventoryConfiguration succeeded");
+        } catch (ObsException e) {
+            System.out.println("GetInventoryConfiguration failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("GetInventoryConfiguration failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0419.html b/docs/obs_3rd_party/java_sdk/obs_21_0419.html new file mode 100644 index 000000000..5a5e2f092 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0419.html @@ -0,0 +1,377 @@ + + +

Listing Inventory Rules

+

Function

This API returns a list of all inventory rules for the bucket.

+
+

Restrictions

  • To list inventory rules for a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetInventoryConfiguration in IAM or GetInventoryConfiguration in a bucket policy).
+
+

Method

obsClient.listInventoryConfiguration(ListInventoryConfigurationRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 ListInventoryConfigurationRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 2 ListInventoryConfigurationResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

inventoryConfigurations

+

List<InventoryConfiguration>

+

Explanation:

+

All inventory configurations of the bucket. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 InventoryConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

configurationId

+

String

+

Yes

+

Explanation:

+

ID of a bucket inventory rule.

+

Restrictions:

+

The rule ID allows letters (a–z, A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

+

Value range:

+

The value can be up to 64 characters long.

+

Default value:

+

None

+

isEnabled

+

boolean

+

Yes

+

Explanation:

+

Whether the bucket inventory rule is enabled.

+

Value range:

+

true: The rule is enabled, and an inventory file is generated.

+

false: The rule is disabled. No inventory file is generated.

+

Default value:

+

true

+

objectPrefix

+

String

+

No

+

Explanation:

+

Used to filter objects. Only objects with the specified name prefix are included in the inventory.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

frequency

+

String

+

Yes

+

Explanation:

+

Intervals when inventories are generated. You can set this parameter to Daily or Weekly. An inventory is generated within one hour from when it is configured for the first time. Then it is generated at the specified intervals.

+

Value range:

+

Daily: Inventories are generated once a day.

+

Weekly: Inventories are generated once a week.

+

Default value:

+

None

+

inventoryFormat

+

String

+

Yes

+

Explanation:

+

Inventory file format. Only the CSV format is supported.

+

Value range:

+

CSV

+

Default value:

+

None

+

destinationBucket

+

String

+

Yes

+

Explanation:

+

Name of the bucket for storing inventories.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

inventoryPrefix

+

String

+

No

+

Explanation:

+

The prefix of the inventory file name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

If you do not specify this parameter, BucketInventory is used as the prefix by default.

+

includedObjectVersions

+

String

+

Yes

+

Explanation:

+

Whether versions of objects are included in an inventory.

+

Value range:

+
  • If this parameter is set to All, all the versions of objects are included in the inventory, and version-related fields are added to the inventory, including: VersionId, IsLatest, and DeleteMarker.
  • If this parameter is set to Current, the inventory only lists information about the current object version and does not include any version-related fields.
+

Default value:

+

None

+

optionalFields

+

ArrayList<String>

+

No

+

Explanation:

+

Additional object metadata fields that are contained in an inventory file.

+

Value range:

+

Size: Object size.

+

LastModifiedDate: Last time when the object was modified.

+

StorageClass: The storage class of the object.

+

ETag: The ETag value of the object.

+

IsMultipartUploaded: Whether the object was uploaded in a multipart upload.

+

ReplicationStatus: The cross-region replication status of the object.

+

EncryptionStatus: The encryption status of the object.

+

Default value:

+

None

+
+
+
+

Code Examples

This example lists all inventory files of bucket example-bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.inventory.InventoryConfiguration;
+import com.obs.services.model.inventory.ListInventoryConfigurationRequest;
+import com.obs.services.model.inventory.ListInventoryConfigurationResult;
+import java.util.List;
+public class ListInventoryConfigurations001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the following parameters.
+            String exampleBucketName = "example-bucket";
+            ListInventoryConfigurationRequest request = new ListInventoryConfigurationRequest(exampleBucketName);
+            // List all inventory rules.
+            ListInventoryConfigurationResult result = obsClient.listInventoryConfiguration(request);
+            List<InventoryConfiguration> inventoryConfigurations = result.getInventoryConfigurations();
+            //Print all parameters in all inventory rules.
+            for (InventoryConfiguration inventoryConfiguration : inventoryConfigurations) {
+                System.out.println("ConfigurationId:" + inventoryConfiguration.getConfigurationId());
+                System.out.println("DestinationBucket:" + inventoryConfiguration.getDestinationBucket());
+                System.out.println("InventoryFormat:" + inventoryConfiguration.getInventoryFormat());
+                System.out.println("Enabled:" + inventoryConfiguration.getEnabled());
+                System.out.println("Frequency:" + inventoryConfiguration.getFrequency());
+                System.out.println("IncludedObjectVersions:" + inventoryConfiguration.getIncludedObjectVersions());
+                System.out.println("InventoryPrefix:" + inventoryConfiguration.getInventoryPrefix());
+                System.out.println("ObjectPrefix:" + inventoryConfiguration.getObjectPrefix());
+                System.out.println("OptionalFields:" + inventoryConfiguration.getOptionalFields());
+                System.out.println("--------------------------------");
+            }
+            // Print the HTTP status code.
+            System.out.println("HTTP Code: " + result.getStatusCode());
+            System.out.println("ListInventoryConfiguration succeeded");
+        } catch (ObsException e) {
+            System.out.println("ListInventoryConfiguration failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("ListInventoryConfiguration failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0420.html b/docs/obs_3rd_party/java_sdk/obs_21_0420.html new file mode 100644 index 000000000..86f9e7c51 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0420.html @@ -0,0 +1,208 @@ + + +

Deleting an Inventory Rule

+

Function

This API deletes an inventory rule (identified by configurationId) from the bucket.

+
+

Restrictions

  • To delete a bucket inventory rule, you must be the bucket owner or have the required permission (obs:bucket:DeleteBucketInventoryConfiguration in IAM or DeleteBucketInventoryConfiguration in a bucket policy).
+
+

Method

obsClient.deleteInventoryConfiguration(DeleteInventoryConfigurationRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + + + + + + +
Table 1 DeleteInventoryConfigurationRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

configurationId

+

String

+

Yes

+

Explanation:

+

ID of the inventory rule to be deleted. The ID can be up to 64 bytes long and allows letters (a–z, A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 2 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the inventory rule whose ID is exampleConfigId001 for bucket example-bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.inventory.DeleteInventoryConfigurationRequest;
+import com.obs.services.model.inventory.GetInventoryConfigurationRequest;
+import com.obs.services.model.inventory.GetInventoryConfigurationResult;
+import com.obs.services.model.inventory.InventoryConfiguration;
+public class DeleteInventoryConfiguration001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the following parameters.
+            String exampleBucketName = "example-bucket";
+            String exampleConfigurationId = "exampleConfigId001";
+            DeleteInventoryConfigurationRequest request =
+                    new DeleteInventoryConfigurationRequest(exampleBucketName, exampleConfigurationId);
+            // Delete the inventory rule.
+            HeaderResponse result = obsClient.deleteInventoryConfiguration(request);
+            // Print the HTTP status code.
+            System.out.println("HTTP Code: " + result.getStatusCode());
+            System.out.println("DeleteInventoryConfiguration succeeded");
+        } catch (ObsException e) {
+            System.out.println("DeleteInventoryConfiguration failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("DeleteInventoryConfiguration failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0421.html b/docs/obs_3rd_party/java_sdk/obs_21_0421.html new file mode 100644 index 000000000..9522d69f6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0421.html @@ -0,0 +1,21 @@ + + +

Bucket Inventory

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0600.html b/docs/obs_3rd_party/java_sdk/obs_21_0600.html new file mode 100644 index 000000000..215ecfe81 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0600.html @@ -0,0 +1,31 @@ + + +

Object Upload

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0601.html b/docs/obs_3rd_party/java_sdk/obs_21_0601.html new file mode 100644 index 000000000..390988d7a --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0601.html @@ -0,0 +1,14 @@ + + +

Overview

+

In OBS, objects are basic data units that users can perform operations on. OBS Java SDK provides abundant APIs for object upload in the following methods:

+ +

The SDK supports the upload of objects whose size ranges from 0 KB to 5 GB. For streaming upload, appendable upload, and file-based upload, data to be uploaded cannot be larger than 5 GB. If the file is larger than 5 GB, multipart upload (where each part is smaller than 5 GB) is suitable. Browser-based upload allows files to be uploaded through a browser.

+

If you grant anonymous users the read permission for an object during the upload, anonymous users can access the object through a URL after the upload is complete. The object URL is in the format of https://bucket name.domain name/directory level/object name. If the object resides in the root directory of the bucket, its URL does not contain directory levels.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0602.html b/docs/obs_3rd_party/java_sdk/obs_21_0602.html new file mode 100644 index 000000000..f0a97260c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0602.html @@ -0,0 +1,1525 @@ + + +

Uploading an Object - Streaming

+

Function

This API uploads a local file to OBS over the Internet. These files can be texts, images, videos, or any other type of files.

+

You can upload texts, images, videos, or any other types of files smaller than 5 GB. In a streaming upload, java.io.InputStream is used as the object data source. You can call ObsClient.putObject to upload data streams to OBS.

+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, refer to Multipart Upload.
  • To upload a local file, you are advised to use a file-based upload. For details, see Uploading an Object - File-Based.
+
+

Method

obsClient.putObject(PutObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 4.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined when an object is created. Refer to Table 6 to choose the option you need.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 6 to configure the required parameters.
+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Information about the server-side encryption header. For details, see Table 14.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Information about the server-side encryption header. For details, see Table 13.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.

+

Value range:

+

An integer greater than 0, in days

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 18.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Size of the object.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

Multipurpose Internet Mail Extensions (MIME) type of the object to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Object storage class that can be specified at object creation. If this parameter is not specified, the object inherits the storage class of the bucket where it is to be uploaded by default.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 11.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 7.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 8.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 9.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 10 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 11 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 17.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

AES256

+

Value range:

+

See Table 16.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 14 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 15.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 16.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 15 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 16 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 17 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + +
Table 18 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used to obtain the upload progress. For details, see Table 19.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 19 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 20.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 20 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 21 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Object storage class. If the storage class is Standard, leave this parameter blank.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Code Example 1: Uploading a Byte Array

The following code is used to upload the Hello OBS character string to the examplebucket bucket and name it objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import java.io.ByteArrayInputStream;
+public class PutObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload a string and convert it to a byte array.
+            String content = "Hello OBS";
+            obsClient.putObject("examplebucket", "objectname", new ByteArrayInputStream(content.getBytes()));
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example 2: Uploading a Network Stream

The following code is used to upload the http://www.a.com network stream to the examplebucket bucket and name it objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import java.io.InputStream;
+import java.net.URL;
+public class PutObject002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload a network stream.
+            InputStream inputStream = new URL("http://www.a.com").openStream();
+            obsClient.putObject("examplebucket", "objectname", inputStream);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example 3: Uploading a File Stream

The following code is used to upload the localfile file stream to the objectname object in the dir directory of bucketname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+import java.io.FileInputStream;
+public class PutObject003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Path of the local file to be uploaded, in which the file name must be specified.
+            FileInputStream fis = new FileInputStream(new File("localfile"));
+            obsClient.putObject("examplebucket", "dir/objectname", fis);
+            // Path of the local file to be uploaded, in which the file name must be specified.
+            FileInputStream fis2 = new FileInputStream(new File("localfile2"));
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname2");
+            request.setInput(fis2);
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0603.html b/docs/obs_3rd_party/java_sdk/obs_21_0603.html new file mode 100644 index 000000000..8fa3a2d2e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0603.html @@ -0,0 +1,1322 @@ + + +

Uploading an Object - File-Based

+

Function

This API uploads local files to OBS over the Internet. The file to be uploaded can be of any type.

+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+
+

Method

obsClient.putObject(PutObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 19.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined when an object is created. Refer to Table 12 to choose the option you need.

+

Value range:

+
  • To use a pre-defined ACL, see Table 21 for the available options.
  • To use a user-defined ACL, see Table 12 to configure the required parameters.
+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 14.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 13.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.

+

Value range:

+

An integer greater than 0, in days

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 3.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + +
Table 3 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress status. For details, see Obtaining the Upload Progress.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS used for encrypting objects.

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on DEW.
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 9 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 10 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 12 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 13.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 14.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 13 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 14 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 16.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 15.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 15 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 17.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 17 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 18 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 19 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Size of the object.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Object storage class that can be specified at object creation. If this parameter is not specified, the object inherits the storage class of the bucket where it is to be uploaded by default.

+

Value range:

+

See Table 20.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 20 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 21 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 20.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads local files to bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload files.
+            // localfile indicates the path of the local file to be uploaded, in which the file name must be specified.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectkey");
+            request.setFile(new File("localfile"));
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0604.html b/docs/obs_3rd_party/java_sdk/obs_21_0604.html new file mode 100644 index 000000000..d1eb65a98 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0604.html @@ -0,0 +1,343 @@ + + +

Obtaining the Upload Progress

+

Function

This API returns the upload progress of a specified object.

+

You can call PutObjectRequest.setProgressListener to obtain the upload progress.

+
+

Restrictions

  • To obtain the upload progress, you must have the obs:object:PutObject permission.
  • You can query the upload progress when uploading an object in streaming, file-based, multipart, appendable, or resumable mode.
  • If the value of ProgressStatus.getTransferPercentage() is -1, the content is uploaded in streaming mode. In this case, you must configure the Content-Length parameter.
+
+

Method

PutObjectRequest.setProgressListener(ProgressListener progressListener)

+
+

Request parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

progressListener

+

ProgressListener

+

Yes

+

Explanation:

+

Data transmission listener for obtaining the upload progress. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + +
Table 3 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+
+

Code Examples

This example returns the progress of uploading local file exampleLocalFilePath to bucket examplebucket as object objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ProgressListener;
+import com.obs.services.model.ProgressStatus;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject005 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload a file.
+            PutObjectRequest request = new PutObjectRequest("examplebucket", "exampleobject");
+            request.setFile(new File("exampleLocalFilePath"));
+            request.setProgressListener(
+                    new ProgressListener() {
+                        @Override
+                        public void progressChanged(ProgressStatus status) {
+                            // Obtain the average upload rate.
+                            System.out.println("AverageSpeed:" + status.getAverageSpeed());
+                             // Obtain the upload progress in percentage.
+                            System.out.println("TransferPercentage:" + status.getTransferPercentage());
+                        }
+                    });
+            // Refresh the upload progress each time 1 MB data is uploaded.
+            request.setProgressInterval(1024 * 1024L);
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
This example returns the progress of uploading local file exampleFileName in a stream to bucket examplebucket as object objectname.
import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.ProgressListener;
+import com.obs.services.model.ProgressStatus;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+import java.io.FileInputStream;
+public class PutObjectByInputStreamWithProgress {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the bucket.
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+        String endPoint = "https://obs.region.example.com";
+        ObsConfiguration obsConfiguration = new ObsConfiguration();
+        obsConfiguration.setEndPoint(endPoint);
+        // Create an ObsClient instance.
+        try (ObsClient obsClient = new ObsClient(ak, sk, securityToken, obsConfiguration)) {
+            String exampleBucket = "examplebucket";
+            String exampleObject = "objectname";
+            String fileToUpload = "exampleFileName";
+            long contentLength = new File(fileToUpload).length();
+            PutObjectRequest request = new PutObjectRequest(exampleBucket, exampleObject, new FileInputStream(fileToUpload));
+            ObjectMetadata objectMetadata = new ObjectMetadata();
+            // Streaming uploads require the object attribute Content-Length must be configured.
+            // Otherwise, ProgressStatus.getTransferPercentage () returns -1.
+            objectMetadata.setContentLength(contentLength);
+            request.setMetadata(objectMetadata);
+            request.setProgressListener(
+                new ProgressListener() {
+                    @Override
+                    public void progressChanged(ProgressStatus status) {
+                            // Obtain the average upload rate.
+                        System.out.println("AverageSpeed:" + status.getAverageSpeed());
+                             // Obtain the upload progress in percentage.
+                        System.out.println("TransferPercentage:" + status.getTransferPercentage());
+                    }
+                });
+            // Refresh the upload progress each time 1 MB data is uploaded.
+            request.setProgressInterval(1024 * 1024L);
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0605.html b/docs/obs_3rd_party/java_sdk/obs_21_0605.html new file mode 100644 index 000000000..1f0839737 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0605.html @@ -0,0 +1,1317 @@ + + +

Creating a Folder

+

Function

This API creates a folder in an existing bucket to manage data in OBS.

+

OBS does not involve folders like in a file system. All elements in buckets are objects. To create a folder in OBS is essentially to create an object whose size is 0 and whose name ends with a slash (/). Such objects are no different from other objects (you can perform normal operations on them such as download and delete), except that they are displayed as folders in OBS console.

+
+

Restrictions

  • To create a folder, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • To create a multi-level folder, you only need to create the folder with the last level. For example, if you want to create a folder named src1/src2/src3/, create it directly. You do not need to create folders src1/ and src1/src2/ first.
+
+

Method

obsClient.putObject(PutObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 14.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined when an object is created. Refer to Table 15 to choose the option you need.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 15 to configure the required parameters.
+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 14.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 13.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.

+

Value range:

+

An integer greater than 0, in days

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 10.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on DEW.
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 10 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 12 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 13 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 14 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Size of the object.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object to be uploaded. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 15 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 16.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 17.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 17 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 19.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 19 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 20.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 20 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 21 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Code Examples

This example uses the object upload operation to create folder parent_directory/ in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import java.io.ByteArrayInputStream;
+public class PutObject006 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Create a folder.
+            final String keySuffixWithSlash = "parent_directory/";
+            obsClient.putObject("examplebucket", keySuffixWithSlash, new ByteArrayInputStream(new byte[0]));
+            // Create an object in the folder.
+            obsClient.putObject(
+                    "examplebucket", keySuffixWithSlash + "objectname", new ByteArrayInputStream("Hello OBS".getBytes()));
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0606.html b/docs/obs_3rd_party/java_sdk/obs_21_0606.html new file mode 100644 index 000000000..62ef3a96c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0606.html @@ -0,0 +1,1738 @@ + + +

Configuring Object Metadata

+

Function

This API configures metadata for an object when uploading it. Object metadata include the object length, MIME type, MD5 value (for verification), storage class, and custom object metadata. You can configure metadata for an object that is being uploaded in streaming, file-based, or multipart mode or when copying an object.

+
+

Restrictions

  • To configure the metadata of an object when uploading it, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • An object can have multiple pieces of metadata. The metadata size cannot exceed 8 KB in total.
  • Currently, metadata names cannot contain non-ASCII characters. If such characters are contained in a metadata value, the value must be Base64-encoded.
+
+

Method

obsClient.putObject(PutObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 14.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined when an object is created. Refer to Table 15 to choose the option you need.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 15 to configure the required parameters.
+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 9.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 8.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.

+

Value range:

+

An integer greater than 0, in days.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 10.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 10 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 12 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 13 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 14 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the file.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the file.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Object storage class that can be specified at object creation. If this parameter is not specified, the object inherits the storage class of the bucket where it is to be uploaded by default.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The metadata size cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 15 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 16.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 17.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 17 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 19.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 19 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 20.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 20 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 21 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Object storage class that can be specified at object creation. If this parameter is not specified, the object inherits the storage class of the bucket where it is to be uploaded by default.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Code Example: Setting the Length for an Object

This example uploads local file localfile to bucket examplebucket as object objectname and sets its length to 1024 * 1024L.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import java.io.File;
+import java.io.IOException;
+public class PutObject007 {
+    public static void main(String[] args) throws IOException {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the length for an object.
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.setContentLength(1024 * 1024L); // 1MB
+            obsClient.putObject("examplebucket", "objectname", new File("localfile"), metadata);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Setting the MIME Type for an Object

This example uploads local file localimage.jpg to bucket examplebucket as object objectname.jpg and sets the MIME type of the object to image/jpeg.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import java.io.File;
+public class PutObject008 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the MIME type for an object.
+            // Upload an image.
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.setContentType("image/jpeg");
+            obsClient.putObject("examplebucket", "objectname.jpg", new File("localimage.jpg"), metadata);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Setting the MD5 Value for an Object

This example uploads local file localimage.jpg to bucket examplebucket as object objectname and calls ObsClient.base64Md5 to calculate the Content-MD5 header.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+public class PutObject009 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the MD5 value for an object.
+            // Upload an image.
+            ObjectMetadata metadata = new ObjectMetadata();
+            // Your file's Base64-encoded MD5
+            String base64Md5 = obsClient.base64Md5(Files.newInputStream(Paths.get("localimage.jpg")));
+            metadata.setContentMd5(base64Md5);
+            obsClient.putObject("examplebucket", "objectname", new File("localimage.jpg"), metadata);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Customizing Metadata for an Object

This example uploads local file localfile to object objectname in bucket examplebucket, customizes two pieces of metadata named property1 and property2, and sets their respective values to property-value1 and property-value2.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import java.io.File;
+public class PutObject011 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set user-defined metadata for the object.
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.addUserMetadata("property1", "property-value1");
+            metadata.getMetadata().put("property2", "property-value2");
+            obsClient.putObject("examplebucket", "objectname", new File("localfile"), metadata);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Setting the Storage Class for an Object

This example uploads local file localfile to bucket exampleBucket as object objectname and sets the object storage class to Warm.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.StorageClassEnum;
+import java.io.File;
+public class PutObject010 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the storage class for an object.
+            ObjectMetadata metadata = new ObjectMetadata();
+            // Set the storage class of the object to Warm.
+            metadata.setObjectStorageClass(StorageClassEnum.WARM);
+            obsClient.putObject("examplebucket", "objectname", new File("localfile"), metadata);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0607.html b/docs/obs_3rd_party/java_sdk/obs_21_0607.html new file mode 100644 index 000000000..8dff3a538 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0607.html @@ -0,0 +1,29 @@ + + +

Multipart Upload

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0608.html b/docs/obs_3rd_party/java_sdk/obs_21_0608.html new file mode 100644 index 000000000..d6f50886c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0608.html @@ -0,0 +1,1326 @@ + + +

Configuring Lifecycle Rules

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes. The object expiration time set using this API takes precedence over that set in a bucket lifecycle rule.

+

You can also set the object expiration time when uploading an object or initiating a multipart upload.

+
  • Objects in the Warm storage class have a minimum storage period of 30 days and those in the Cold storage class have a minimum storage period of 90 days. After an object is transitioned to the Cold storage class, if it stays in this storage class for less than 90 days, you still need to pay for a full 90 days.
+
+
+

Restrictions

  • There is no limit on the number of lifecycle rules in a bucket, but the total size of XML descriptions about all lifecycle rules in a bucket cannot exceed 20 KB.
  • A maximum of 20 lifecycle rules can be configured for a parallel file system.
  • To configure a lifecycle rule for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutLifecycleConfiguration in IAM or PutLifecycleConfiguration in a bucket policy).
  • This API only specifies the time duration in days after which an object will expire. The OBS server automatically clears expired objects.
+
+

Method

obsClient.putObject(PutObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 14.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 15 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 9.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 8.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+
  • This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.
  • Expired objects will be permanently deleted and cannot be recovered.
+

Value range:

+

An integer greater than 0, in days.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 10.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for server-side encryption. Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 10 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 12 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 13 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 14 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the file.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the file.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 13.

+

Restrictions:

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The metadata size cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 15 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 16.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 17.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 17 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 19.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 19 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 20.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 20 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 21 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Object storage class. If the storage class is Standard, this parameter is left blank.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version ID will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Code Examples

This example uploads localfile to object objectname in bucket examplebucket and sets the object expiration time to 30 days.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject012 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setFile(new File("localfile"));
+            // When uploading an object, set the object to expire after 30 days.
+            request.setExpires(30);
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0609.html b/docs/obs_3rd_party/java_sdk/obs_21_0609.html new file mode 100644 index 000000000..356aa485e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0609.html @@ -0,0 +1,1346 @@ + + +

Uploading an Object - Append

+

Function

  1. This API uploads a file or folder to an existing OBS bucket. These files can be texts, images, videos, or any other type of files.
  2. The appendObject operation adds data to the end of an object in a specified bucket. If there is no object with the same names in the bucket, a new object is created. The latest modification time of the object is updated each time an upload is appended.
  3. After an appendable upload is successful, you can call AppendObjectResult.getNextPosition or use the ObsClient.getObjectMetadata API to get the start position for next appending.
+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • The size of each append upload cannot exceed 5 GB.
  • A maximum of 10,000 appendable uploads can be performed on a single object. If you attempt to append more than 10,000 uploads to an object, OBS returns 409 Conflict with an error code ObjectNotAppendable.
  • If the object storage class is COLD (Cold), this API cannot be called.
  • Objects uploaded using ObsClient.putObject, referred to as common objects, can overwrite objects uploaded using ObsClient.appendObject, referred to as appendable objects. Data cannot be appended to an appendable object anymore once the object has been overwritten by a common object.
  • You can append data to an existing object only if it is appendable. Otherwise, an exception will be reported (HTTP status code 409). To check whether an object is appendable, see Obtaining Object Metadata.
+
+

Method

obsClient.appendObject(AppendObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

AppendObjectRequest

+

Yes

+

Explanation:

+

Request parameters for an append upload. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 AppendObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 14.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 15 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 9.

+

Restrictions:

+

If you use SSE-KMS encryption, the encryption header you configure, such as x-obs-server-side-encryption, only needs to be carried when the object is uploaded for the first time and no object with the same name exists in the bucket.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 8.

+

Restrictions:

+

If you use SSE-C encryption, the encryption header you configure, such as x-obs-server-side-encryption, must be carried in each append upload.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call.

+

Value range:

+

An integer greater than 0, in days.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 4.

+

position

+

long

+

Yes

+

Explanation:

+

Position where the object data is appended.

+

Restrictions:

+

For an object to be appended, the value of position must be set to 0 when the object is uploaded for the first time. The value of position will be carried in the x-obs-next-append-position header of the response returned by the server when the object is successfully uploaded next time.

+

Default value:

+

None

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 10.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for server-side encryption. Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 10 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 12 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 13 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 14 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the file.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the file.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The metadata size cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 15 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 16.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 17.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 17 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 19.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + +
Table 19 GranteeInterface

Parameter

+

Description

+

CanonicalGrantee

+

Explanation:

+

Grantee (user) information. For details, see Table 20.

+

GroupGrantee

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 20 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 21 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 AppendObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of the appended content. The ETag returned for the append upload is the ETag for the appended content, not that for the entire object. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An uploaded object or copied object has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

nextPosition

+

long

+

Explanation:

+

Position from which the next append upload starts

+

Default value:

+

None

+
+
+
+

Code Examples

This example appends data to object objectname in bucket examplebucket by specifying an append position.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AppendObjectRequest;
+import com.obs.services.model.AppendObjectResult;
+import com.obs.services.model.ObjectMetadata;
+import java.io.ByteArrayInputStream;
+public class AppendObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try (ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint)) {
+            // Append data for the first time.
+            AppendObjectRequest request = new AppendObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setPosition(0);
+            request.setInput(new ByteArrayInputStream("Hello OBS".getBytes()));
+            AppendObjectResult result = obsClient.appendObject(request);
+            // Append data for the second time.
+            request.setPosition(result.getNextPosition());
+            request.setInput(new ByteArrayInputStream("Hello OBS Again".getBytes()));
+            result = obsClient.appendObject(request);
+            System.out.println("appendObject successfully");
+            System.out.println("NextPosition:" + result.getNextPosition());
+            System.out.println("Etag:" + result.getEtag());
+            // Use the API for obtaining object metadata to get the start position for the next append.
+            ObjectMetadata metadata = obsClient.getObjectMetadata("examplebucket", "objectname");
+            System.out.println("NextPosition from metadata:" + metadata.getNextPosition());
+        } catch (ObsException e) {
+            System.out.println("appendObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("appendObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0611.html b/docs/obs_3rd_party/java_sdk/obs_21_0611.html new file mode 100644 index 000000000..f205b0170 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0611.html @@ -0,0 +1,1318 @@ + + +

Uploading an Object - Resumable

+

Function

The resumable upload is an encapsulated and enhanced version of the multipart upload used for dealing with possible upload failures of large files when the network connection is unstable or a program crashes. This API splits the file into multiple parts and uploads them individually. The upload result of each part is recorded in a checkpoint file in real time. A success message is returned only when all parts are uploaded. If any parts fail, an error message is returned telling you to call the API again to upload the failed parts. Since the checkpoint file contains the progress of each part, it saves you uploading all parts again in the event of an error.

+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • The file uploaded by the resumable upload API must exceed 100 KB.
  • To obtain the progress of the last upload, you must enable resumable upload when you use this API.
+
+

Method

obsClient.uploadFile(UploadFileRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 uploadFile

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

UploadFileRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 UploadFileRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

objectMetadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 14.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 15 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 9.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 8.

+

Default value:

+

None

+

enableCheckpoint

+

boolean

+

No

+

Explanation:

+

Whether to enable the resumable mode.

+

Value range:

+

true: The resumable mode is enabled.

+

false: The resumable mode is disabled.

+

Default value:

+

false

+

checkpointFile

+

String

+

No

+

Explanation:

+

Path of a file generated for recording the progress of a resumable upload. The file contains the information about parts and the upload progress.

+

Restrictions:

+

This parameter is valid only for resumable uploads.

+

Default value:

+

If this parameter is left blank, the progress file will be in the same directory as the local file to be uploaded.

+

uploadFile

+

String

+

Yes

+

Explanation:

+

Full path of the file or folder to be uploaded, for example, aa/bb.txt or aa/.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener, used for obtaining the upload progress. For details, see Table 4.

+

partSize

+

long

+

No

+

Explanation:

+

Part size.

+

Value range:

+

The value ranges from 100 KB to 5 GB, in bytes.

+

Default value:

+

9 MB

+

taskNum

+

int

+

No

+

Explanation:

+

Maximum number of files that can be uploaded concurrently in a multipart upload.

+

Value range:

+

An integer from 1 to 10000

+

Default value:

+

1, indicating concurrent uploads are not used.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 10.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on DEW.
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 10 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 12 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 13 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 14 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 13.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 15 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 16.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 17.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 17 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 19.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + +
Table 19 GranteeInterface

Parameter

+

Description

+

CanonicalGrantee

+

Explanation:

+

Grantee (user) information. For details, see Table 20.

+

GroupGrantee

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 21.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 20 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 21 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 22 CompleteMultipartUploadResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version number will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Code Examples

This example uses the resumable method to upload localfile to bucket examplebucket as object objectKey.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CompleteMultipartUploadResult;
+import com.obs.services.model.UploadFileRequest;
+public class UploadFile001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            UploadFileRequest request = new UploadFileRequest("examplebucket", "objectKey");
+            // Configure the local file to be uploaded. localfile is the path of the file to be uploaded. You must specify a file name with the extension.
+            request.setUploadFile("localfile");
+            // Set the maximum number of parts that can be concurrently uploaded.
+            request.setTaskNum(5);
+            // Set the part size to 10 MB.
+            request.setPartSize(10 * 1024 * 1024);
+            // Enable the resumable upload.
+            request.setEnableCheckpoint(true);
+            // Perform a resumable upload.
+            CompleteMultipartUploadResult result = obsClient.uploadFile(request);
+            System.out.println("UploadFile successfully");
+        } catch (ObsException e) {
+            // If there is an exception, you can call the API again to resume the upload.
+            System.out.println("UploadFile failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("UploadFile failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0612.html b/docs/obs_3rd_party/java_sdk/obs_21_0612.html new file mode 100644 index 000000000..2eb09a512 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0612.html @@ -0,0 +1,388 @@ + + +

Uploading an Object - Browser-Based

+

Function

This API uploads an object up to 5 GB to a specified bucket in HTML form.

+

You can call ObsClient.createPostSignature to generate request parameters for a browser-based upload. The procedure is as follows:

+
  1. Call ObsClient.createPostSignature to generate request parameters for authentication.
  2. Prepare an HTML form.
  3. Enter the request parameters in the page.
  4. Select a local file and upload it in browser-based mode.
+

There are two request parameters generated for authentication:

+
  • Policy, which corresponds to the policy parameter in the form
  • Signature, which corresponds to the signature parameter in the form
+
+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
+
  • Values of policy and signature in the HTML form are obtained from the returned results of ObsClient.createPostSignature.
  • During the object upload, the value of contentType needs to be manually changed to the corresponding Content-Type value.
+
+

Method

obsClient.createPostSignature(PostSignatureRequest request)

+ +
+ + + + + + + + + + + +
Table 1 createPostSignature

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PostSignatureRequest

+

Yes

+

Explanation:

+

Request parameters for a browser-based upload. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PostSignatureRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

No

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

No

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

requestDate

+

Date

+

No

+

Explanation:

+

Time the request is initiated.

+

Default value:

+

None

+

expiryDate

+

Date

+

No

+

Explanation:

+

Date of expiry.

+

Default value:

+

None

+

expires

+

long

+

No

+

Explanation:

+

Validity period of authentication for a browser-based upload

+

Value range:

+

An integer greater than 0, in seconds.

+

Default value:

+

300

+

conditions

+

List<String>

+

No

+

Explanation:

+

The conditions specified for the form. The SDK uses the specified value to calculate the policy and ignores the formParams.

+

Default value:

+

None

+

formParams

+

Map<String, Object>

+

No

+

Explanation:

+

Form parameters in the request. String indicates the name of the form parameter, and Object indicates the value of the form parameter.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 3 PostSignatureResponse

Parameter

+

Type

+

Description

+

OriginPolicy

+

String

+

Explanation:

+

Value of Policy that is not encoded by Base64. This parameter can only be used for verification. For example:

+

{"expiration":"2023-09-12T12:52:59Z","conditions":[{"content-type":"text/plain"},{"bucket":"examplebucket"},{"key":"example/objectname"},]}"

+

Default value:

+

None

+

Policy

+

String

+

Explanation:

+

Base64-encoded value of the policy. For example:

+

eyJleHBpcmF0aW9uIjoiMjAyMy0wOS0xMlQxMjo1Mjo1OVoiLCJjb25kaXRpb25zIjpbeyJjb250ZW50LXR5cGUiOiJ0ZXh0L3BsYWluIn0seyJidWNrZXQiOiJleGFtcGxlYnVja2V0In0seyJrZXkiOiJleGFtcGxlL29iamVjdG5hbWUifSxdfQ==

+

Default value:

+

None

+

Signature

+

String

+

Explanation:

+

signature in the form. For example:

+

g0jQr4v9VWd1Q2FOFDG6LGfV9Cw=

+

Default value:

+

None

+
+
+
+

Code Examples

This example generates authorization parameters for a browser-based upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PostSignatureRequest;
+import com.obs.services.model.PostSignatureResponse;
+import java.util.HashMap;
+import java.util.Map;
+public class PostObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Generate a request for a browser-based upload.
+            PostSignatureRequest request = new PostSignatureRequest();
+            // Set form parameters.
+            Map<String, Object> formParams = new HashMap<String, Object>();
+            // Set the object ACL to public read.
+            formParams.put("x-obs-acl", "public-read");
+            // Set the MIME type for an object.
+            formParams.put("content-type", "text/plain");
+            request.setFormParams(formParams);
+            // Set the validity period for the browser-based upload request, in seconds.
+            request.setExpires(3600);
+            PostSignatureResponse response = obsClient.createPostSignature(request);
+            System.out.println("createPostSignature successfully");
+            // Obtain the request parameters.
+            System.out.println("Policy:" + response.getPolicy());
+            System.out.println("Signature:" + response.getSignature());
+        } catch (ObsException e) {
+            System.out.println("createPostSignature failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("createPostSignature failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

This example is an HTML form.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
<html>
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+<form action="http://bucketname.your-endpoint/" method="post" enctype="multipart/form-data">
+    Object key
+    <!-- Object name -->
+    <input type="text" name="key" value="objectname" />
+    <p>
+        ACL
+        <!-- Object ACL -->
+        <input type="text" name="x-obs-acl" value="public-read" />
+    <p>
+        Content-Type
+        <!-- Object MIME type -->
+        <input type="text" name="content-type" value="text/plain" />
+    <p>
+        <!-- Use the value returned by PostSignatureResponse.getPolicy(). -->
+        <input type="hidden" name="policy" value="*** Provide your policy ***" />
+        <!-- AK -->
+        <input type="hidden" name="AccessKeyId" value="*** Provide your access key ***"/>
+        <!-- Signature string -->
+        <input type="hidden" name="signature" value="*** Provide your signature ***"/>
+        <!-- If x-obs-security-token exists, remove the comment for the following line and specify the actual value of x-obs-security-token. -->
+        <!-- <input type="hidden" name="x-obs-security-token" value="*** Provide your x-obs-security-token ***"/>-->
+        <input name="file" type="file" />
+        <input name="submit" value="Upload" type="submit" />
+</form>
+</body>
+</html>
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0614.html b/docs/obs_3rd_party/java_sdk/obs_21_0614.html new file mode 100644 index 000000000..bcf24081b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0614.html @@ -0,0 +1,19 @@ + + +

Multipart Upload Overview

+

Function

You can upload large files using multipart upload. Multipart upload is applicable to many scenarios, including:

+
  • Files to be uploaded are larger than 100 MB.
  • The network condition is poor. Connection to the OBS server is constantly down.
  • Sizes of files to be uploaded are uncertain.
+

+

A multipart upload has the following advantages:

+
  • Higher throughput: You can upload parts in parallel to improve throughput.
  • Quick recovery from network failures: Uploading an object in parts helps minimize the impact of upload interruptions caused by network failures.
  • Flexible suspension and resumption of object uploads: You can upload parts at any time. A multipart upload will not expire after being initiated. You must explicitly complete or abort a multipart upload.
  • No need to know the size before uploading an object: You can upload an object while creating it.
+

+

A multipart upload consists of the following steps:

+
  1. Initiate a multipart upload (ObsClient.initiateMultipartUpload).
  2. Upload parts one by one or concurrently (ObsClient.uploadPart).
  3. Assemble parts (ObsClient.completeMultipartUpload) or abort the multipart upload (ObsClient.abortMultipartUpload).
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0615.html b/docs/obs_3rd_party/java_sdk/obs_21_0615.html new file mode 100644 index 000000000..1de9200a0 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0615.html @@ -0,0 +1,1141 @@ + + +

Initiating a Multipart Upload

+

Function

This API initiates a multipart upload and returns a globally unique upload ID. You can use this upload ID in your subsequent requests including abortMultipartUpload, listMultipartUploads, and listParts.

+
+

Restrictions

  • To initiate a multipart upload, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • After initiating a multipart upload and uploading one or more parts, you must assemble the parts or abort the multipart upload.
+
+

Method

obsClient.initiateMultipartUpload(InitiateMultipartUploadRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

InitiateMultipartUploadRequest

+

Yes

+

Explanation:

+

Request parameters for initiating a multipart upload. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 InitiateMultipartUploadRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 11.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL that can be specified at bucket creation. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 12 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 6.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 5.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured when uploading an object or using the x-obs-expires header in a metadata API call after the object has been uploaded.

+

Value range:

+

An integer greater than 0, in days.

+

Default value:

+

None

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 7.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in bytes.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for server-side encryption. Objects are encrypted using SSE-KMS on the server side.

+

Value range:

+

kms. For details, see Table 8.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + +
Table 7 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 8 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 9 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 10 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the file.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The metadata size cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 12 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 13.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 14.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 13 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 14 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 16.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 15.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 15 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 17.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 17 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 18 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+
+

List of returned results

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 19 InitiateMultipartUploadResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

uploadId

+

String

+

Explanation:

+

The ID created by the OBS server to identify the multipart upload globally.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Name of the bucket involved in the multipart upload.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Name of the object to be uploaded. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+
+

Code Examples

This example initiates a multipart upload for object objectname in bucket examplebucket and obtains the upload ID.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.InitiateMultipartUploadRequest;
+import com.obs.services.model.InitiateMultipartUploadResult;
+import com.obs.services.model.ObjectMetadata;
+public class InitiateMultipartUpload001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest("examplebucket", "objectname");
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.addUserMetadata("property", "property-value");
+            metadata.setContentType("text/plain");
+            request.setMetadata(metadata);
+            InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request);
+            String uploadId = result.getUploadId();
+            System.out.println("initiateMultipartUpload successfully");
+            System.out.println("uploadId:" + uploadId);
+        } catch (ObsException e) {
+            System.out.println("initiateMultipartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("initiateMultipartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0616.html b/docs/obs_3rd_party/java_sdk/obs_21_0616.html new file mode 100644 index 000000000..c2e820406 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0616.html @@ -0,0 +1,713 @@ + + +

Uploading a Part

+

Function

After a multipart upload is initiated, this API uploads a part to a specified bucket. In the upload request, the multipart upload ID must be included. Except for the part lastly being uploaded whose size ranges from 0 to 5 GB, sizes of the other parts range from 100 KB to 5 GB. Part numbers can be any number from 1 to 10,000.

+

When uploading a part, you must specify its upload ID and part number. A part number uniquely identifies a part and its position in the object you are uploading. If you upload a new part with the same part number as that of a previous part, the previously uploaded part will be overwritten. Whenever you upload a part, OBS returns the ETag header in the response. For each part upload task, you must record the part number and ETag value. These values are required in subsequent requests for you to complete a multipart upload.

+
+

Restrictions

  • To upload a part, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • After initiating a multipart upload and uploading one or more parts, you must assemble the parts or abort the multipart upload.
  • partNumber in a multipart upload must be unique. When the same partNumber of the same object is concurrently uploaded, last write wins policy is applied. The time of last write is defined as the time when the part metadata is created. To ensure data accuracy, the client must be locked to ensure concurrent uploads of the same part of the same object. Concurrent uploads for different parts of the same object do not need to be locked.
+
+

Method

obsClient.uploadPart(UploadPartRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

UploadPartRequest

+

Yes

+

Explanation:

+

Request parameters for uploading a part. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 UploadPartRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

partNumber

+

int

+

Yes

+

Explanation:

+

Part number.

+

Value range:

+

The value ranges from 1 to 10000. If a part number is not within the range, OBS returns error code 400 Bad Request.

+

Default value:

+

None

+

uploadId

+

String

+

Yes

+

Explanation:

+

Multipart upload ID, which can be returned by initiating a multipart upload, for example, 000001648453845DBB78F2340DD460D8.

+

Restrictions:

+

The value must contain 32 characters.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Restrictions:

+

You must specify either file or input.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Restrictions:

+

You must specify either file or input. If one of the two parameters is left blank, the other must be specified.

+

Default value:

+

None

+

offset

+

long

+

No

+

Explanation:

+

Start offset of a part in the source file. This parameter is not supported for streams.

+

Value range:

+

A non-negative integer not exceeding the size of the object to be uploaded, in bytes.

+

Default value:

+

0

+

partSize

+

Long

+

No

+

Explanation:

+

Part size.

+

Restrictions:

+
  • Except the part last uploaded, each of the other parts must be larger than 100 KB. The size of each part is not verified during its upload, because the system cannot define whether it is the last part. The part size is verified when the parts are assembled.
  • The minimum part size supported by an OBS 3.0 bucket is 100 KB, and that supported by an OBS 2.0 bucket is 5 MB.
+

Value range:

+

The value ranges from 100 KB to 5 GB, in bytes.

+

Default value:

+

102400

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 3.

+

Default value:

+

None

+

attachMd5

+

boolean

+

No

+

Explanation:

+

Whether to automatically calculate the MD5 value of the data to be uploaded. To ensure data integrity, set UploadPartRequest.setAttachMd5 to true to make the SDK automatically calculate the MD5 value (valid only when the data source is a local file) of each part and add the MD5 value to the Content-MD5 request header. The OBS server will calculate the MD5 value of the uploaded data and compare it with the MD5 value calculated by the SDK.

+

Restrictions:

+

If attachMd5 and contentMd5 are used at the same time, attachMd5 is ignored.

+

Value range:

+

true: The MD5 value of the data to be uploaded is automatically calculated.

+

false: The MD5 value of the data to be uploaded is not automatically calculated.

+

Default value:

+

false

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the part to be uploaded, which uniquely identifies the content of the uploaded part and can be used to identify whether the object content is changed.

+

Restrictions:

+

If attachMd5 and contentMd5 are used at the same time, attachMd5 is ignored.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 7.

+

progressInterval

+

long

+

No

+

Explanation:

+

Interval for reporting the upload progress, in bytes. For example, 1024 * 1024L indicates that the upload progress is reported each time 1 MB data is uploaded.

+

Default value:

+

100 * 1024L

+

autoClose

+

boolean

+

No

+

Explanation:

+

Whether to automatically close data streams after the upload is complete.

+

Value range:

+

true: The data stream is automatically closed.

+

false: The data stream is not automatically closed.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 4.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + +
Table 5 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + +
Table 7 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the upload progress. For details, see Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 8 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 9.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 10 UploadPartResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

partNumber

+

int

+

Explanation:

+

Part number.

+

Value range:

+

[1,10000]

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of a part. ETag is the unique identifier of the part contents and is used to determine whether the contents of a part are changed. For example, if the ETag value is A when a part is uploaded and is B when the part is downloaded, this indicates the contents of the part are changed. The ETag reflects changes only to the contents of a part, not its metadata. Parts created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Code Examples

This example calls obsClient.uploadPart to upload parts to object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PartEtag;
+import com.obs.services.model.UploadPartRequest;
+import com.obs.services.model.UploadPartResult;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+public class UploadPart001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String uploadId = "upload id from initiateMultipartUpload";
+            List<PartEtag> partEtags = new ArrayList<PartEtag>();
+            // Upload the first part.
+            UploadPartRequest request = new UploadPartRequest("examplebucket", "objectname");
+            // Set the upload ID.
+            request.setUploadId(uploadId);
+            // Set the part number, which ranges from 1 to 10000.
+            request.setPartNumber(1);
+            // Specify the large file to be uploaded.
+            request.setFile(new File("localfile"));
+            // Set the part size.
+            request.setPartSize(5 * 1024 * 1024L);
+            UploadPartResult result = obsClient.uploadPart(request);
+            partEtags.add(new PartEtag(result.getEtag(), result.getPartNumber()));
+            // Upload the second part.
+            request = new UploadPartRequest("examplebucket", "objectname");
+            // Set the upload ID.
+            request.setUploadId(uploadId);
+            // Set the part number.
+            request.setPartNumber(2);
+            // Specify the large file to be uploaded.
+            request.setFile(new File("localfile"));
+            // Set the offset of the second part. This parameter takes effect only when a file is uploaded. This parameter is not supported for streams.
+            request.setOffset(5 * 1024 * 1024L);
+            // Set the part size.
+            request.setPartSize(5 * 1024 * 1024L);
+            result = obsClient.uploadPart(request);
+            partEtags.add(new PartEtag(result.getEtag(), result.getPartNumber()));
+            System.out.println("uploadPart successfully");
+        } catch (ObsException e) {
+            System.out.println("uploadPart failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("uploadPart failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0617.html b/docs/obs_3rd_party/java_sdk/obs_21_0617.html new file mode 100644 index 000000000..6ee3be815 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0617.html @@ -0,0 +1,424 @@ + + +

Assembling Parts

+

Function

This API assembles the uploaded parts to complete the multipart upload. Before performing this operation, you cannot download the uploaded data. When assembling parts, you need to copy the additional message header information recorded during the multipart upload initiation to the object metadata. Such information is processed the same way the information in a common object upload is processed. In the case of assembling parts concurrently, last write wins is applied, but the time of last write is defined as the time when a multipart upload was initiated.

+

As long as the multipart upload is not aborted, all uploaded parts occupy the space. However, after you assembled the specified parts, those uploaded but not assembled will be deleted to free up space.

+

When assembling parts, OBS creates an object by putting part numbers in ascending order. If any object metadata is provided in the initiation of the multipart upload, OBS will associate the metadata with the object. After the multipart upload is complete, the parts will no longer exist. A part assembling request must contain the upload ID, part numbers, and a list of corresponding ETag values. In response to the request, the ETag that uniquely identifies the assembled parts is contained. This ETag is not the MD5 hash value of the entire object.

+
+

Restrictions

  • To assemble parts, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • After a multipart upload is complete, the uploaded parts that are not assembled will be automatically deleted and cannot be recovered. Before assembling parts, use the API for listing uploaded parts to check all parts to ensure that no part is missed.
+
+

Method

obsClient.completeMultipartUpload(CompleteMultipartUploadRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

CompleteMultipartUploadRequest

+

Yes

+

Explanation:

+

Request parameters for assembling parts. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CompleteMultipartUploadRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

partEtag

+

List<PartEtag>

+

Yes

+

Explanation:

+

List of parts to be assembled. For details, see Table 3.

+

uploadId

+

String

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

encodingType

+

String

+

No

+

Explanation:

+

Encoding type for objectKey in the response. If objectKey in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode objectKey.

+

Value range:

+

url

+

Default value:

+

None. If you leave this parameter blank, encoding is not applied.

+

userHeaders

+

HashMap<String, String>

+

No

+

Explanation:

+

User header list. In HashMap, the String key and value indicate the name and value of the user header field respectively. The SDK does not process the userHeaders and instead transparently transmits it to the server for later use.

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 PartEtag

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

etag

+

String

+

Yes

+

Explanation:

+

Part ETag. Base64-encoded, 128-bit MD5 value of the part.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

partNumber

+

Integer

+

Yes

+

Explanation:

+

Part number. Part numbers can be inconsecutive.

+

Value range:

+

An integer ranging from 1 to 10000.

+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 CompleteMultipartUploadResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket in which parts are assembled.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

The name of the object the parts are assembled into.

+

An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

URL of the object the parts are assembled into.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Version ID of the object the parts are assembled into. If versioning is enabled for the bucket, the object version number will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectUrl

+

String

+

Explanation:

+

Full path to the object the parts are assembled into.

+

Default value:

+

None

+

encodingType

+

String

+

Explanation:

+

Encoding type for objectKey in the response. If objectKey in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode objectKey.

+

Value range:

+

url

+

Default value:

+

None. If you leave this parameter blank, encoding is not applied.

+
+
+
+

Code Examples

This example calls ObsClient.completeMultipartUpload to assemble parts into object objectname in bucket examplebucket based on uploadId and partEtags.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CompleteMultipartUploadRequest;
+import com.obs.services.model.PartEtag;
+import java.util.ArrayList;
+import java.util.List;
+public class CompleteMultipartUpload001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String uploadId = "upload id from initiateMultipartUpload";
+            List<PartEtag> partEtags = new ArrayList<PartEtag>();
+            // First part
+            PartEtag part1 = new PartEtag();
+            part1.setPartNumber(1);
+            part1.seteTag("etag1");
+            partEtags.add(part1);
+            // Second part
+            PartEtag part2 = new PartEtag();
+            part2.setPartNumber(2);
+            part2.setEtag("etag2");
+            partEtags.add(part2);
+            CompleteMultipartUploadRequest request =
+                    new CompleteMultipartUploadRequest("examplebucket", "objectname", uploadId, partEtags);
+            obsClient.completeMultipartUpload(request);
+            System.out.println("completeMultipartUpload successfully");
+        } catch (ObsException e) {
+            System.out.println("CompleteMultipartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("completeMultipartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0618.html b/docs/obs_3rd_party/java_sdk/obs_21_0618.html new file mode 100644 index 000000000..37eb7c5cf --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0618.html @@ -0,0 +1,248 @@ + + +

Code Example of a Multipart Upload

+

Multipart upload is mainly used for large file upload or when the network connection is poor.

+

You can use UploadPartRequest.setOffset and UploadPartRequest.setPartSize to set the start and end positions for uploading a part.

+

This example uploads a large file by concurrently uploading parts.

+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CompleteMultipartUploadRequest;
+import com.obs.services.model.InitiateMultipartUploadRequest;
+import com.obs.services.model.InitiateMultipartUploadResult;
+import com.obs.services.model.PartEtag;
+import com.obs.services.model.UploadPartRequest;
+import com.obs.services.model.UploadPartResult;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+public class ConcurrentUploadPart001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            final String bucketName = "examplebucket";
+            final String objectKey = "objectname";
+            // Initialize the thread pool.
+            ExecutorService executorService = Executors.newFixedThreadPool(20);
+            final File largeFile = new File("localfile");
+            // Initiate a multipart upload.
+            InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest(bucketName, objectKey);
+            InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request);
+            final String uploadId = result.getUploadId();
+            System.out.println("\t" + uploadId + "\n");
+            // Set the part size to 100 MB.
+            long partSize = 100 * 1024 * 1024L;
+            long fileSize = largeFile.length();
+            // Calculate the number of parts to be uploaded.
+            long partCount = fileSize % partSize == 0 ? fileSize / partSize : fileSize / partSize + 1;
+            final List<PartEtag> partEtags = Collections.synchronizedList(new ArrayList<PartEtag>());
+            // Start uploading parts concurrently.
+            for (int i = 0; i < partCount; i++) {
+                // Set the start position of a part in the file.
+                final long offset = i * partSize;
+                // Set the part size.
+                final long currPartSize = (i + 1 == partCount) ? fileSize - offset : partSize;
+                // Set the part number.
+                final int partNumber = i + 1;
+                executorService.execute(
+                        new Runnable() {
+                            @Override
+                            public void run() {
+                                UploadPartRequest uploadPartRequest = new UploadPartRequest();
+                                uploadPartRequest.setBucketName(bucketName);
+                                uploadPartRequest.setObjectKey(objectKey);
+                                uploadPartRequest.setUploadId(uploadId);
+                                uploadPartRequest.setFile(largeFile);
+                                uploadPartRequest.setPartSize(currPartSize);
+                                uploadPartRequest.setOffset(offset);
+                                uploadPartRequest.setPartNumber(partNumber);
+                                UploadPartResult uploadPartResult;
+                                try {
+                                    uploadPartResult = obsClient.uploadPart(uploadPartRequest);
+                                    System.out.println("Part#" + partNumber + " done\n");
+                                    partEtags.add(
+                                            new PartEtag(uploadPartResult.getEtag(), uploadPartResult.getPartNumber()));
+                                } catch (ObsException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        });
+            }
+            // Wait until the upload is complete.
+            executorService.shutdown();
+            while (!executorService.isTerminated()) {
+                try {
+                    executorService.awaitTermination(5, TimeUnit.SECONDS);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+            // Assemble parts.
+            CompleteMultipartUploadRequest completeMultipartUploadRequest =
+                    new CompleteMultipartUploadRequest(bucketName, objectKey, uploadId, partEtags);
+            obsClient.completeMultipartUpload(completeMultipartUploadRequest);
+            System.out.println("completeMultipartUpload successfully");
+        } catch (ObsException e) {
+            System.out.println("CompleteMultipartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("completeMultipartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0619.html b/docs/obs_3rd_party/java_sdk/obs_21_0619.html new file mode 100644 index 000000000..8afe448f9 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0619.html @@ -0,0 +1,236 @@ + + +

Aborting a Multipart Upload

+

Function

This API aborts a multipart upload using the multipart upload ID.

+

After a multipart upload is aborted, the upload ID cannot be used to upload any part. The storage occupied by any uploaded parts will be released. If any part uploads are in progress, aborting the multipart upload might or might not make the uploads successful. To release the storage occupied by all uploaded parts, you can only abort the multipart upload after all parts have been uploaded.

+
+

Restrictions

  • To abort a multipart upload, you must be the bucket owner or have the required permission (obs:object:AbortMultipartUpload in IAM or AbortMultipartUpload in a bucket policy).
+
+

Method

obsClient.abortMultipartUpload(AbortMultipartUploadRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

AbortMultipartUploadRequest

+

Yes

+

Explanation:

+

Request parameters for aborting a multipart upload. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 AbortMultipartUploadRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Bucket name.

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

String

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example calls ObsClient.abortMultipartUpload to abort the multipart upload of object objectname in bucket examplebucket based on the upload ID obtained during the multipart upload initiation.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AbortMultipartUploadRequest;
+public class AbortMultipartUpload001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String uploadId = "upload id from initiateMultipartUpload";
+            // Abort the multipart upload request.
+            AbortMultipartUploadRequest request = new AbortMultipartUploadRequest("examplebucket", "objectname", uploadId);
+            // Abort the multipart upload API.
+            obsClient.abortMultipartUpload(request);
+            System.out.println("AbortMultipartUpload successfully");
+        } catch (ObsException e) {
+            System.out.println("AbortMultipartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("AbortMultipartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0620.html b/docs/obs_3rd_party/java_sdk/obs_21_0620.html new file mode 100644 index 000000000..e52ab0bda --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0620.html @@ -0,0 +1,692 @@ + + +

Listing Uploaded Parts

+

Function

This API lists the uploaded parts in a specified bucket. This request must contain the multipart upload ID.

+

You can list the uploaded parts of a specified multipart upload or of all ongoing multipart uploads. A maximum of 1,000 uploaded parts can be returned in a response. If your multipart upload has more than 1,000 parts, you need to send multiple requests to list all uploaded parts. Assembled parts will not be listed.

+
+

Restrictions

  • To list uploaded parts, you must be the bucket owner or have the required permission (obs:object:ListMultipartUploadParts in IAM or ListMultipartUploadParts in a bucket policy).
+
+

Method

obsClient.listParts(ListPartsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

ListPartsRequest

+

Yes

+

Explanation:

+

Request parameters for listing uploaded parts. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ListPartsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

String

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

maxParts

+

Integer

+

No

+

Explanation:

+

Maximum number of parts that can be listed per page.

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 parts are returned.

+

Value range:

+

The value ranges from 1 to 1000.

+

Default value:

+

1000

+

partNumberMarker

+

Integer

+

No

+

Explanation:

+

Part number the listing starts from.

+

Restrictions:

+

OBS lists only parts with greater numbers than that specified by this parameter.

+

Default value:

+

None

+

encodingType

+

String

+

No

+

Explanation:

+

Encoding type for key in the response. If key in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode key.

+

Value range:

+

url

+

Default value:

+

None. If you leave this parameter blank, encoding is not applied.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ListPartsResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

bucket

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

key

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

String

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

initiator

+

Owner

+

Explanation:

+

Initiator of the multipart upload. For details, see Table 6.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the multipart upload, which is consistent with initiator. For details, see Table 6.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the object to be uploaded.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

multipartList

+

List<Multipart>

+

Explanation:

+

List of uploaded parts. For details, see Table 4.

+

Default value:

+

None

+

maxParts

+

Integer

+

Explanation:

+

Maximum number of parts that can be listed per page, which is consistent with that set in the request.

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 parts are returned.

+

Value range:

+

The value ranges from 1 to 1000.

+

Default value:

+

1000

+

isTruncated

+

boolean

+

Explanation:

+

Whether all parts are returned in the response.

+

Value range:

+
  • true: Not all parts are returned.
  • false: All parts are returned.
+

Default value:

+

None

+

partNumberMarker

+

String

+

Explanation:

+

Part number after which part listing begins, which is consistent with that set in the request.

+

Default value:

+

None

+

nextPartNumberMarker

+

String

+

Explanation:

+

Part number to start with for the next part listing request. If only part of the uploaded parts are returned for the current request, this parameter is included in the response for setting partNumberMarker in the subsequent request.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 Multipart

Parameter

+

Type

+

Description

+

partNumber

+

Integer

+

Explanation:

+

Part number.

+

Value range:

+

An integer ranging from 1 to 10000.

+

Default value:

+

None

+

lastModified

+

Date

+

Explanation:

+

Last time the part was uploaded.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

Part ETag. Base64-encoded, 128-bit MD5 value of the part.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

size

+

Long

+

Explanation:

+

Part size.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 5 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+
+

Code Example: Listing Up to 1,000 Uploaded Parts

This example lists up to 1,000 parts uploaded to object objectname in bucket examplebucket based on the upload ID obtained through initiateMultipartUpload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListPartsRequest;
+import com.obs.services.model.ListPartsResult;
+import com.obs.services.model.Multipart;
+public class ListParts001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String uploadId = "upload id from initiateMultipartUpload";
+            // List uploaded parts. uploadId is obtained from the initiateMultipartUpload API.
+            ListPartsRequest request = new ListPartsRequest("examplebucket", "objectname");
+            request.setUploadId(uploadId);
+            ListPartsResult result = obsClient.listParts(request);
+            for (Multipart part : result.getMultipartList()) {
+                // Part number, specified during the upload
+                System.out.println("PartNumber:" + part.getPartNumber());
+                // Part size
+                System.out.println("Size:" + part.getSize());
+                // Part ETag
+                System.out.println("Etag:" + part.getEtag());
+                // Time when the part was last uploaded
+                System.out.println("LastModified:" + part.getLastModified());
+            }
+            System.out.println("listParts successfully");
+        } catch (ObsException e) {
+            System.out.println("listParts failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listParts failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing All Uploaded Parts

This example lists over 1,000 parts using pagination.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListPartsRequest;
+import com.obs.services.model.ListPartsResult;
+import com.obs.services.model.Multipart;
+public class ListParts002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String uploadId = "upload id from initiateMultipartUpload";
+            // List uploaded parts. uploadId is obtained from the initiateMultipartUpload API.
+            ListPartsRequest request = new ListPartsRequest("examplebucket", "objectname");
+            request.setUploadId(uploadId);
+            ListPartsResult result;
+            do {
+                result = obsClient.listParts(request);
+                for (Multipart part : result.getMultipartList()) {
+                    // Part number, specified during the upload
+                    System.out.println("PartNumber:" + part.getPartNumber());
+                    // Part size
+                    System.out.println("Size:" + part.getSize());
+                    // Part ETag
+                    System.out.println("Etag:" + part.getEtag());
+                    // Time when the part was last uploaded
+                    System.out.println("LastModified:" + part.getLastModified());
+                }
+                request.setPartNumberMarker(Integer.parseInt(result.getNextPartNumberMarker()));
+            } while (result.isTruncated());
+            System.out.println("listParts successfully");
+        } catch (ObsException e) {
+            System.out.println("listParts failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listParts failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0621.html b/docs/obs_3rd_party/java_sdk/obs_21_0621.html new file mode 100644 index 000000000..ee9fbf3fd --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0621.html @@ -0,0 +1,722 @@ + + +

Listing Multipart Uploads

+

Function

This API lists ongoing multipart uploads.

+

Ongoing multipart uploads are the multipart uploads that have been initiated but have not been completed or aborted. A maximum of 1,000 multipart uploads can be returned in a response. If there are over 1,000 ongoing tasks satisfying the list criteria, you need to send more requests to query additional multipart uploads.

+
+

Restrictions

  • To list multipart uploads, you must be the bucket owner or have the required permission (obs:bucket:ListBucketMultipartUploads in IAM or ListBucketMultipartUploads in a bucket policy).
  • By default, only the bucket owner and multipart upload initiator have this permission. The bucket owner can grant others the ListBucketMultipartUploads permission.
+
+

Method

obsClient.listMultipartUploads(ListMultipartUploadsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

ListMultipartUploadsRequest

+

Yes

+

Explanation:

+

Request parameters for listing multipart uploads. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ListMultipartUploadsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

String

+

No

+

Explanation:

+

Prefix that the object names in the multipart uploads to be listed must contain.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads of logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all multipart uploads in the bucket will be returned.

+

Restrictions:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

delimiter

+

String

+

No

+

Explanation:

+

Object names are grouped by this parameter, which is often used with prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one commonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one commonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix, and bbcde is grouped separately into another commonPrefixes with bbcd as the prefix.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

maxUploads

+

Integer

+

No

+

Explanation:

+

Maximum number of multipart uploads to list.

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 multipart uploads are returned.

+

Value range:

+

An integer from 1 to 1000

+

Default value:

+

1000

+

keyMarker

+

String

+

No

+

Explanation:

+

Object name after which the multipart upload listing begins.

+

Value range:

+

The value of nextKeyMarker in the response body of the last request.

+

Default value:

+

None

+

uploadIdMarker

+

String

+

No

+

Explanation:

+

Upload ID after which the multipart upload listing begins.

+

Restrictions:

+

This parameter must be used together with keyMarker, indicating multipart uploads with IDs greater than the specified uploadIdMarker for the specified keyMarker are listed.

+

Value range:

+

The value of nextUploadIdMarker in the response body of the last request.

+

Default value:

+

None

+

encodingType

+

String

+

No

+

Explanation:

+

Encoding type for some elements in the response. If delimiter, keyMarker, prefix, nextKeyMarker, and objectKey contain control characters that are not supported by the XML 1.0 standard, you can set encodingType to encode delimiter, keyMarker, prefix (including the prefix in commonPrefixes), nextKeyMarker, and objectKey in the response.

+

Value range:

+

url

+

Default value:

+

None. If you leave this parameter blank, encoding is not applied.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 MultipartUploadListing

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

bucket

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

keyMarker

+

String

+

Explanation:

+

Object name after which the multipart upload listing begins, which is consistent with that set in the request.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadIdMarker

+

String

+

Explanation:

+

Upload ID after which the multipart upload listing begins, which is consistent with that set in the request.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

nextKeyMarker

+

String

+

Explanation:

+

Object name to start with for the next multipart upload listing request. If only part of multipart uploads are returned for the current request, this parameter is included in the response for setting keyMarker in the subsequent request.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

nextUploadIdMarker

+

String

+

Explanation:

+

Upload ID to start with for the next multipart upload listing request. It is used with the nextKeyMarker parameter. If only part of multipart uploads are returned for the current request, this parameter is included in the response for setting uploadIdMarker in the subsequent request.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

prefix

+

String

+

Explanation:

+

Object name prefix in multipart uploads, which is consistent with that set in the request.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, the multipart uploads of logs/day1, logs/day2, and logs/day3 will be returned. If you leave this parameter blank, all multipart uploads in the bucket will be returned.

+

Restrictions:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

maxUploads

+

int

+

Explanation:

+

Maximum number of listed multipart uploads, which is consistent with that set in the request.

+

Restrictions:

+

If the specified value is greater than 1000, only 1,000 multipart uploads are returned.

+

Value range:

+

An integer from 1 to 1000

+

Default value:

+

1000

+

truncated

+

boolean

+

Explanation:

+

Whether all multipart uploads are returned in the response.

+

Value range:

+
  • true: Not all multipart uploads are returned.
  • false: All multipart uploads are returned.
+

Default value:

+

None

+

multipartTaskList

+

List<MultipartUpload>

+

Explanation:

+

List of multipart uploads. For details, see Table 4.

+

delimiter

+

String

+

Explanation:

+

A character used to group object names in multipart uploads, which is consistent with that set in the request. This parameter is often used with prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one commonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one commonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a commonPrefixes with abcd as the prefix, and bbcde is grouped separately into another commonPrefixes with bbcd as the prefix.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

commonPrefixes

+

String[]

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified).

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 MultipartUpload

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

uploadId

+

String

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 1 to 32 characters.

+

Default value:

+

None

+

initiatedDate

+

java.util.Date

+

Explanation:

+

Time when the multipart upload is initiated.

+

Restrictions:

+

The time must be in the ISO8601 format.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the object to be uploaded.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

initiator

+

Owner

+

Explanation:

+

Initiator of the multipart upload. For details, see Table 6.

+

owner

+

Owner

+

Explanation:

+

Owner of the multipart upload, which is consistent with initiator. For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 5 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+
+

Code Example: Listing Multipart Uploads

This example lists up to 1,000 multipart uploads of bucket examplebucket.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListMultipartUploadsRequest;
+import com.obs.services.model.MultipartUpload;
+import com.obs.services.model.MultipartUploadListing;
+public class ListMultipartUploads001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            ListMultipartUploadsRequest request = new ListMultipartUploadsRequest("examplebucket");
+            MultipartUploadListing result = obsClient.listMultipartUploads(request);
+            for (MultipartUpload upload : result.getMultipartTaskList()) {
+                System.out.println("UploadId:" + upload.getUploadId());
+                System.out.println("ObjectKey:" + upload.getObjectKey());
+                System.out.println("InitiatedDate:" + upload.getInitiatedDate());
+            }
+            System.out.println("ListMultipartUploads successfully");
+        } catch (ObsException e) {
+            System.out.println("ListMultipartUploads failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("ListMultipartUploads failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Listing Multipart Uploads Using Pagination

This example lists over 1,000 multipart uploads using pagination.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListMultipartUploadsRequest;
+import com.obs.services.model.MultipartUpload;
+import com.obs.services.model.MultipartUploadListing;
+public class ListMultipartUploads002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            ListMultipartUploadsRequest request = new ListMultipartUploadsRequest("examplebucket");
+            MultipartUploadListing result;
+            do {
+                result = obsClient.listMultipartUploads(request);
+                for (MultipartUpload upload : result.getMultipartTaskList()) {
+                    System.out.println("UploadId:" + upload.getUploadId());
+                    System.out.println("ObjectKey:" + upload.getObjectKey());
+                    System.out.println("InitiatedDate:" + upload.getInitiatedDate());
+                }
+                request.setKeyMarker(result.getNextKeyMarker());
+                request.setUploadIdMarker(result.getNextUploadIdMarker());
+            } while (result.isTruncated());
+            System.out.println("ListMultipartUploads successfully");
+        } catch (ObsException e) {
+            System.out.println("ListMultipartUploads failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("ListMultipartUploads failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0700.html b/docs/obs_3rd_party/java_sdk/obs_21_0700.html new file mode 100644 index 000000000..87976bef5 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0700.html @@ -0,0 +1,27 @@ + + +

Object Download

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0701.html b/docs/obs_3rd_party/java_sdk/obs_21_0701.html new file mode 100644 index 000000000..8f0d4dca8 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0701.html @@ -0,0 +1,117 @@ + + +

Overview

+

OBS Java SDK provides abundant APIs for object download in the following methods:

+ +

Request Parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

isEncodeHeaders

+

boolean

+

No

+

Whether to automatically encode the request header. The default value is true.

+

userHeaders

+

HashMap<String, String>

+

No

+

User's header field.

+

ifMatchTag

+

String

+

No

+

Returns the object content if the object's ETag is the same as this parameter value. Otherwise, an error is reported.

+

ifNoneMatchTag

+

String

+

No

+

Returns the object content if the object's ETag is different from this parameter value. Otherwise, an error is reported.

+

ifModifiedSince

+

Date

+

No

+

Returns the object if it has been modified since the specified time; otherwise, an error is returned.

+

ifUnmodifiedSince

+

Date

+

No

+

Returns the object if it has not been modified since the specified time; otherwise, an error is returned.

+

rangeStart

+

Long

+

No

+

Start byte for a partial download.

+

rangeEnd

+

Long

+

No

+

End byte for a partial download.

+

sseCHeader

+

SseCHeader

+

No

+

Information about the server-side encryption header.

+

versionId

+

String

+

No

+

Version number.

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0702.html b/docs/obs_3rd_party/java_sdk/obs_21_0702.html new file mode 100644 index 000000000..70332a952 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0702.html @@ -0,0 +1,976 @@ + + +

Downloading an Object - Streaming

+

Function

When you call ObsClient.getObject, an instance of ObsObject will be returned. This instance contains the contents of the object such as its name, attributes, input stream, and which bucket it is stored in. You can perform operations on the object input stream to read the contents to a local file or memory.

+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
  • Objects in the Cold storage class can be downloaded only when they are restored.
  • Object input streams obtained by ObsObject.getObjectContent must be closed explicitly. Otherwise, resource leakage occurs.
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the download progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 4.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example downloads objectname from examplebucket using streaming.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+public class GetObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Download the object using streaming.
+            ObsObject obsObject = obsClient.getObject("examplebucket", "objectname");
+            // Read the object content.
+            System.out.println("Object content:");
+            InputStream input = obsObject.getObjectContent();
+            byte[] b = new byte[1024];
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            int len;
+            while ((len = input.read(b)) != -1) {
+                bos.write(b, 0, len);
+            }
+            System.out.println("getObjectContent successfully");
+            System.out.println(new String(bos.toByteArray()));
+            bos.close();
+            input.close();
+        } catch (ObsException e) {
+            System.out.println("getObjectContent failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectContent failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0703.html b/docs/obs_3rd_party/java_sdk/obs_21_0703.html new file mode 100644 index 000000000..fc489d5bd --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0703.html @@ -0,0 +1,974 @@ + + +

Downloading an Object - Range-Based

+

Function

This API downloads partial data of an object by specifying a range. If the specified range is from 0 to 1,000, data from byte 0 to byte 1,000, 1,001 bytes in total, are returned. If the specified range is invalid, the whole object is returned.

+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
  • Objects in the Cold storage class can be downloaded only when they are restored.
  • If the specified range is invalid (for example, the start or end position is set to a negative integer, or the start position is greater than the end position), the API throws an exception. If the specified range is valid and the end position is greater than the object size, the entire object is returned.
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the download progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 12.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example downloads part of object objectname in bucket examplebucket by specifying a range from 0l to 1000l.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import java.io.InputStream;
+public class GetObject002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Perform a partial download.
+            GetObjectRequest request = new GetObjectRequest("examplebucket", "objectname");
+            // Set the start point and end point.
+            request.setRangeStart(0l);
+            request.setRangeEnd(1000l);
+            ObsObject obsObject = obsClient.getObject(request);
+            // Read data.
+            byte[] buf = new byte[1024];
+            InputStream in = obsObject.getObjectContent();
+            for (int n = 0; n != -1; ) {
+                n = in.read(buf, 0, buf.length);
+            }
+            System.out.println("GetObject successfully");
+            in.close();
+        } catch (ObsException e) {
+            System.out.println("GetObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("GetObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0704.html b/docs/obs_3rd_party/java_sdk/obs_21_0704.html new file mode 100644 index 000000000..6828ef8e7 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0704.html @@ -0,0 +1,299 @@ + + +

Obtaining the Download Progress

+

Function

This API returns the download progress of a specified object.

+

You can call GetObjectRequest.setProgressInterval to obtain the download progress.

+
+

Restrictions

  • To obtain the download progress, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
  • You can obtain the download progress when downloading an object in streaming, partial, or resumable mode.
+
+

Method

GetObjectRequest.setProgressListener(ProgressListener progressListener)

+
+

Request parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

progressListener

+

ProgressListener

+

Yes

+

Explanation:

+

Data transmission listener used for obtaining the progress. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + +
Table 3 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+
+

Code Examples

This example returns the progress of downloading object objectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.ProgressListener;
+import com.obs.services.model.ProgressStatus;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+public class GetObject003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the download progresses.
+            GetObjectRequest request = new GetObjectRequest("examplebucket", "objectname");
+            request.setProgressListener(
+                    new ProgressListener() {
+                        @Override
+                        public void progressChanged(ProgressStatus status) {
+                            // Obtain the average download rate.
+                            System.out.println("AverageSpeed:" + status.getAverageSpeed());
+                            // Obtain the download progress in percentage.
+                            System.out.println("TransferPercentage:" + status.getTransferPercentage());
+                        }
+                    });
+            // Refresh the download progress each time 1 MB data is downloaded.
+            request.setProgressInterval(1024 * 1024L);
+            ObsObject obsObject = obsClient.getObject(request);
+            // Read the object content.
+            System.out.println("Object content:");
+            InputStream input = obsObject.getObjectContent();
+            byte[] b = new byte[1024];
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            int len;
+            while ((len = input.read(b)) != -1) {
+                bos.write(b, 0, len);
+            }
+            System.out.println("getObjectContent successfully");
+            System.out.println(new String(bos.toByteArray()));
+            bos.close();
+            input.close();
+        } catch (ObsException e) {
+            System.out.println("getObjectContent failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectContent failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0705.html b/docs/obs_3rd_party/java_sdk/obs_21_0705.html new file mode 100644 index 000000000..ce21e7425 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0705.html @@ -0,0 +1,962 @@ + + +

Downloading an Object - Conditional

+

Function

This API returns the objects that meet one or more conditions. If there are no objects that meet the specified conditions, an error is returned.

+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
  • Objects in the Cold storage class can be downloaded only when they are restored.
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+
  1. The ETag of an object is the MD5 value of the object. Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.
  2. If a request includes If-Unmodified-Since or If-Match and the specified condition is not met, 412 Precondition Failed will be returned.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+
  1. Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.
  2. If a request includes If-Modified-Since or If-None-Match, and the specified condition is not met, 304 Not Modified will be returned.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+
  1. The object is returned if it has been modified since the specified time; otherwise, an error is returned.
  2. If a request includes If-Modified-Since or If-None-Match, and the specified condition is not met, 304 Not Modified will be returned.
+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+
  1. The object is returned if it has not been modified since the specified time; otherwise, an error is returned.
  2. If a request includes If-Unmodified-Since or If-Match and the specified condition is not met, 412 Precondition Failed will be returned.
+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 12.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example downloads objectname from examplebucket based on a specific condition. In this example, objectname can be downloaded only when it is modified after 00:00:00 on January 1, 2016.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import java.text.SimpleDateFormat;
+public class GetObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Perform a conditional download.
+            GetObjectRequest request = new GetObjectRequest("examplebucket", "objectname");
+            request.setRangeStart(0l);
+            request.setRangeEnd(1000l);
+            request.setIfModifiedSince(new SimpleDateFormat("yyyy-MM-dd").parse("2016-01-01"));
+            ObsObject obsObject = obsClient.getObject(request);
+            System.out.println("getObject successfully");
+            obsObject.getObjectContent().close();
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0706.html b/docs/obs_3rd_party/java_sdk/obs_21_0706.html new file mode 100644 index 000000000..fff102c98 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0706.html @@ -0,0 +1,950 @@ + + +

Rewriting Response Headers

+

Function

This API rewrites the following HTTP/HTTPS response headers when downloading an object: Content-Type, Content-Language, Expires, Cache-Control, Content-Disposition, and Content-Encoding.

+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the progress. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 12.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example rewrites response headers and downloads object objectname from bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObjectRepleaceMetadata;
+import com.obs.services.model.ObsObject;
+public class GetObject005 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Rewrite the response headers.
+            GetObjectRequest request = new GetObjectRequest("examplebucket", "objectname");
+            ObjectRepleaceMetadata replaceMetadata = new ObjectRepleaceMetadata();
+            replaceMetadata.setContentType("image/jpeg");
+            request.setReplaceMetadata(replaceMetadata);
+            ObsObject obsObject = obsClient.getObject(request);
+            System.out.println(obsObject.getMetadata().getContentType());
+            System.out.println("getObject successfully");
+            obsObject.getObjectContent().close();
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0707.html b/docs/obs_3rd_party/java_sdk/obs_21_0707.html new file mode 100644 index 000000000..ff9db6403 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0707.html @@ -0,0 +1,985 @@ + + +

Obtaining User-defined Metadata

+

Function

Object metadata is a set of key-value pairs that describe the object and is used for object management.

+

This API returns the user-defined object metadata after the object is successfully downloaded.

+
+

Restrictions

  • To obtain object metadata, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the progress. For details, see Table 4.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating Advanced Encryption Standard (AES) is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 12.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example downloads object objectname from bucket examplebucket and returns the user-defined object metadata.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.PutObjectRequest;
+public class GetObject006 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the user-defined metadata.
+            // Upload the object and customize the metadata.
+            PutObjectRequest request = new PutObjectRequest("examplebucket", "objectname");
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.addUserMetadata("property", "property-value");
+            request.setMetadata(metadata);
+            obsClient.putObject(request);
+            // Download the object to obtain the object's user-defined metadata.
+            GetObjectRequest request1 = new GetObjectRequest("examplebucket", "objectname");
+            ObsObject obsObject = obsClient.getObject(request1);
+            System.out.println("getObject successfully");
+            // Get the object metadata.
+            System.out.println(obsObject.getMetadata().getContentType());
+            // Obtain the user-defined metadata named property.
+            System.out.println(obsObject.getMetadata().getUserMetadata("property"));
+            // Obtain all user-defined metadata.
+            System.out.println("allUserMetadata:" + metadata.getAllMetadata());
+            obsObject.getObjectContent().close();
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0708.html b/docs/obs_3rd_party/java_sdk/obs_21_0708.html new file mode 100644 index 000000000..d3361bf4d --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0708.html @@ -0,0 +1,333 @@ + + +

Restoring a Cold Object

+

Function

Cold objects must first be restored before you can download them. Cold objects can be restored in either of the following ways.

+ +
+ + + + + + + + + + + + + +

Option

+

Description

+

Value in OBS Java SDK

+

Expedited

+

Data can be restored within 1 to 5 minutes.

+

RestoreTierEnum.EXPEDITED

+

Standard

+

Data can be restored within 3 to 5 hours. This is the default option.

+

RestoreTierEnum.STANDARD

+
+
+
+

Restrictions

  • To restore a Cold object, you must be the bucket owner or have the required permission (obs:object:RestoreObject in IAM or RestoreObject in a bucket policy.)
  • To prolong the validity period of the Cold data restored, you can repeatedly restore the data, but you will be billed for each restore. After a second restore, the validity period of Standard object copies will be prolonged, and you need to pay for storing these copies during the prolonged period.
+
  • The object specified in ObsClient.restoreObject must be in the Cold storage class. Otherwise, an exception will be thrown when you call this API.
+
+

Method

obsClient.restoreObject(RestoreObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

RestoreObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 RestoreObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Version ID of the Cold object to be restored

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is specified.

+

days

+

int

+

Yes

+

Explanation:

+

After an object is restored, a Standard copy of it is generated. This parameter specifies how long the Standard copy can be retained, that is, the validity period of the restored object.

+

Restrictions:

+

The value must be a positive integer.

+

Value range:

+

The value ranges from 1 to 30, in days.

+

Default value:

+

None

+

tier

+

RestoreTierEnum

+

No

+

Explanation:

+

The restore option, which indicates the time spent on restoring the object.

+

Value range:

+

For details, see Table 3.

+

Default value:

+

Standard

+
+
+ +
+ + + + + + + + + + + + + +
Table 3 RestoreTierEnum

Constant

+

Default Value

+

Description

+

EXPEDITED

+

Expedited

+

Objects can be restored at an expedited speed within 1 to 5 minutes.

+

STANDARD

+

Standard

+

Objects can be restored at a standard speed within 3 to 5 hours.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 4 RestoreObjectStatus

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example restores object objectname from the Cold storage class using ObsClient.restoreObject and downloads it using ObsClient.getObject.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.RestoreObjectRequest;
+import com.obs.services.model.RestoreTierEnum;
+public class GetObject007 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Restore the Cold object.
+            RestoreObjectRequest request = new RestoreObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setDays(1);
+            request.setRestoreTier(RestoreTierEnum.EXPEDITED);
+            obsClient.restoreObject(request);
+            // Wait for the object to be restored.
+            Thread.sleep(60 * 6 * 1000);
+            // Download the object.
+            ObsObject obsObject = obsClient.getObject("examplebucket", "objectname");
+            System.out.println("getObject successfully");
+            obsObject.getObjectContent().close();
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0709.html b/docs/obs_3rd_party/java_sdk/obs_21_0709.html new file mode 100644 index 000000000..09ae36a23 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0709.html @@ -0,0 +1,740 @@ + + +

Downloading an Object - Resumable

+

Function

  1. Downloading large files often fails due to an unstable network or program breakdown. It is a waste of resources to download files again. Moreover, the restarted download may still fail due to an unstable network. To resolve such issues, the resumable download API splits the file to be downloaded into multiple parts and downloads them separately. The download result of each part is recorded in a checkpoint file in real time. Only when all parts are downloaded is a message indicating the download is successful returned. If any parts fail to be downloaded, a message is returned telling you to call the API again to download the failed parts. Since the checkpoint file contains the progress of all parts, it helps you avoid downloading all parts in re-downloads, so that you can enjoy a cost-effective, efficient download.
  2. The resumable download API is an encapsulated and enhanced version of the API for partial download. For details about the partial download, see Downloading an Object - Range-Based.
  3. This API saves resources and improves efficiency upon the re-download, and speeds up the download process by concurrently downloading parts. You do not need to worry about internal service details, such as the creation and deletion of checkpoint files, division of objects, or concurrent downloads of parts.
+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
+
+

Method

obsClient.downloadFile(DownloadFileRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

DownloadFileRequest

+

Yes

+

Explanation:

+

Request parameters for downloading a large object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 DownloadFileRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

downloadFile

+

String

+

No

+

Explanation:

+

Full path of the local directory to which the object is downloaded.

+

Default value:

+

If the value of this parameter is left blank, the downloaded object is saved in the directory where the program is executed.

+

partSize

+

long

+

No

+

Explanation:

+

Part size.

+

Value range:

+

The value ranges from 100 KB to 5 GB, in bytes.

+

Default value:

+

9 MB

+

taskNum

+

int

+

No

+

Explanation:

+

Maximum number of parts that can be downloaded concurrently in a multipart download

+

Value range:

+

The value must be greater than 0, but not exceed the file size divided by the part size, rounded up.

+

Default value:

+

1, indicating concurrent downloads are not used.

+

enableCheckpoint

+

boolean

+

No

+

Explanation:

+

Whether to enable the resumable mode.

+

Value range:

+

true: The resumable mode is enabled.

+

false: The resumable mode is disabled.

+

Default value:

+

false

+

checkpointFile

+

String

+

No

+

Explanation:

+

Path of a file generated for recording the progress of a resumable download. The file contains the information about parts and progress.

+

Restrictions:

+

This parameter is valid only in the resumable mode.

+

Default value:

+

If this parameter is left blank, the checkpoint file will be saved in the current directory.

+

enableCheckSum

+

boolean

+

No

+

Explanation:

+

Whether to verify the file to download. If this function is enabled, before each task restarts, the system verifies whether the file to download is the one used during task initialization.

+

Restrictions:

+

This parameter is valid only in the resumable mode.

+

Value range:

+

true: The file is verified.

+

false: The file is not verified.

+

Default value:

+

false

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID, for example, G001117FCE89978B0000401205D5DC9.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is obtained.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to automatically decode the response headers.

+

Default value:

+

None

+

ifModifiedSince

+

Date

+

No

+

Explanation:

+

Returns the object if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

ifUnmodifiedSince

+

Date

+

No

+

Explanation:

+

Returns the object if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Returns the object content if the object's ETag is the same as the value of this parameter. Otherwise, an error is reported.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Returns the object content if the object's ETag is different from the value of this parameter. Otherwise, an error is reported.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the download progress. For details, see Table 3.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + +
Table 3 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If this header is not set, the default storage class of the bucket is used as the storage class of the object.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + +
Table 8 DownloadFileResult

Parameter

+

Type

+

Description

+

objectMetadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 7.

+
+
+
+

Code Examples

This example downloads object objectname from bucket examplebucket to localfile using the resumable download.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.DownloadFileRequest;
+import com.obs.services.model.DownloadFileResult;
+public class DownloadFile001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            DownloadFileRequest request = new DownloadFileRequest("examplebucket", "objectname");
+            // Set the local path the object will be downloaded to.
+            request.setDownloadFile("localfile");
+            // Set the maximum number of parts that can be concurrently downloaded.
+            request.setTaskNum(5);
+            // Set the part size to 10 MB.
+            request.setPartSize(10 * 1024 * 1024);
+            // Enable the resumable upload.
+            request.setEnableCheckpoint(true);
+            // Perform a resumable download.
+            DownloadFileResult result = obsClient.downloadFile(request);
+            System.out.println("downloadFile successfully");
+            System.out.println("Etag:" + result.getObjectMetadata().getEtag());
+        } catch (ObsException e) {
+            System.out.println("downloadFile failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("downloadFile failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0800.html b/docs/obs_3rd_party/java_sdk/obs_21_0800.html new file mode 100644 index 000000000..1399eefa9 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0800.html @@ -0,0 +1,29 @@ + + +

Object Management

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0801.html b/docs/obs_3rd_party/java_sdk/obs_21_0801.html new file mode 100644 index 000000000..f6047a312 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0801.html @@ -0,0 +1,579 @@ + + +

Obtaining Object Metadata

+

Function

Object metadata is a set of name-value pairs that describe the object and is used for object management.

+

Users with the READ permission on objects can send HEAD requests to retrieve metadata from objects. The metadata of the objects is included in the response.

+

This operation supports server-side encryption.

+
+

Restrictions

  • To obtain object metadata, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
  • You can also call metadata.getOriginalHeaders to obtain information about all original response headers.
+
+

Method

obsClient.getObjectMetadata(GetObjectMetadataRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectMetadataRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining object metadata. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectMetadataRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

userHeaders

+

HashMap<String, String>

+

No

+

Explanation:

+

User header list. In HashMap, the String key and value indicate the name and value of the user header field respectively. The SDK does not process the userHeaders and instead transparently transmits it to the server for later use.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 4.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + +
Table 4 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + +
Table 5 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+
  • If the storage class is Standard, leave this parameter blank.
  • See Table 7.
+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 7 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Code Examples

This example returns the metadata of object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+public class GetObjectMetadata001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the object metadata.
+            ObjectMetadata metadata = obsClient.getObjectMetadata("examplebucket", "objectname");
+            System.out.println("getObjectMetadata successfully");
+            System.out.println("ContentType:" + metadata.getContentType());
+            System.out.println("ContentLength:" + metadata.getContentLength());
+            // Obtain the user-defined metadata.
+            System.out.println("UserMetadata:" + metadata.getUserMetadata("property"));
+            // Obtain all original response headers.
+            System.out.println("OriginalHeaders:" + metadata.getOriginalHeaders());
+        } catch (ObsException e) {
+            System.out.println("getObjectMetadata failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectMetadata failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0802.html b/docs/obs_3rd_party/java_sdk/obs_21_0802.html new file mode 100644 index 000000000..dd5a86b08 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0802.html @@ -0,0 +1,841 @@ + + +

Configuring an Object ACL

+

Function

Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over resources when a bucket or object is created. That is, the bucket creator has full control over the bucket, and the object uploader has full control over the object. Other accounts do not have the permissions to access resources. If resource owners want to grant other accounts the read and write permissions on resources, they can use ACLs. ACLs grant permissions to accounts. After an account is granted permissions, both the account and its IAM users can access the resources. If an object is encrypted with SSE-KMS, the ACL configured for it is not in effect in the cross-tenant case.

+

+
+

An object ACL can be configured in any of the following ways:

+
  1. Code Example: Setting a Pre-defined ACL When Uploading the Object
  2. Code Example: Setting a Pre-defined ACL for the Object
  3. Code Example: Setting an ACL for the Object Directly
+

Restrictions

  • To configure an object ACL, you must be the bucket owner or have the required permission (obs:object:PutObjectAcl in IAM or PutObjectAcl in a bucket policy).
  • An object can have a maximum of 100 rules in its ACL.
+
+

Method

obsClient.setObjectAcl(SetObjectAclRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetObjectAclRequest

+

Yes

+

Explanation:

+

Request parameters for setting an object ACL. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 SetObjectAclRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

acl

+

AccessControlList

+

Yes

+

Explanation:

+

An ACL specified for the object. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 3 for the available options.
  • To use a user-defined ACL, see Table 4 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 3 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

Yes

+

Explanation:

+

Bucket owner information. For details, see Table 5.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 7.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 8.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 9 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 10 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 11 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Setting a Pre-defined ACL When Uploading the Object

This example uploads localfile to bucket examplebucket as object objectname, and specifies a pre-defined ACl during the upload.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject012 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Specify a pre-defined ACL during object upload.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setFile(new File("localfile"));
+            // Set the object ACL to private read and write.
+            request.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            obsClient.putObject(request);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Setting a Pre-defined ACL for the Object

This example specifies a pre-defined ACL of private read and write for object objectname in examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+public class SetObjectAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set a predefined ACL for the object.
+            // Set the object ACL to private read and write.
+            obsClient.setObjectAcl("examplebucket", "objectname", AccessControlList.REST_CANNED_PRIVATE);
+            System.out.println("setObjectAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("setObjectAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setObjectAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Setting an ACL for the Object Directly

This example configures an ACL for object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.CanonicalGrantee;
+import com.obs.services.model.GroupGrantee;
+import com.obs.services.model.Owner;
+import com.obs.services.model.Permission;
+public class SetObjectAcl002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            AccessControlList acl = new AccessControlList();
+            Owner owner = new Owner();
+            owner.setId("ownerid");
+            // (Mandatory) Owner ID 
+            acl.setOwner(owner);
+            //Retain the owner's full control permissions. (Note that if this permission is not set, the owner does not have the access permission.)
+            acl.grantPermission(new CanonicalGrantee("ownerid"), Permission.PERMISSION_FULL_CONTROL);
+            // Grant the full control permission to a specified user.
+            acl.grantPermission(new CanonicalGrantee("userid"), Permission.PERMISSION_FULL_CONTROL);
+            // Grant the read permission to all users.
+            acl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
+            obsClient.setObjectAcl("examplebucket", "objectname", acl);
+            System.out.println("setObjectAcl successfully");
+            System.out.println(acl);
+        } catch (ObsException e) {
+            System.out.println("setObjectAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setObjectAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0803.html b/docs/obs_3rd_party/java_sdk/obs_21_0803.html new file mode 100644 index 000000000..acfab3f5e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0803.html @@ -0,0 +1,1472 @@ + + +

Listing Objects

+

Function

This API lists some or all of the objects in a bucket. You can use parameters such as the prefix, number of returned objects, and start position to list objects that meet specified criteria. Returned objects are listed in alphabetical order by object name.

+
+

Restrictions

  • To list objects in a bucket, you must be the bucket owner or have the required permission (obs:bucket:ListBucket in IAM or ListBucket in a bucket policy).
  • A maximum of 1,000 object versions can be returned in a single request. If a bucket contains more than 1,000 object versions, you can use pagination to list all versions. If ListVersionsResult.isTruncated is true, only part of object versions are returned. In this case, you can use ListVersionsResult.getNextKeyMarker and ListVersionsResult.getNextVersionIdMarker to obtain the start position for the next listing.
+
+

Method

obsClient.listObjects(ListObjectsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

ListObjectsRequest

+

Yes

+

Explanation:

+

Request parameters for listing the objects in a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ListObjectsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

String

+

No

+

Explanation:

+

Name prefix that the objects to be listed must contain.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If this parameter is left blank and there are no other filtering criteria, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

marker

+

String

+

No

+

Explanation:

+

Name of the object to start with when listing objects in a bucket. All objects following this object are listed in alphabetical order by object name.

+

Assume that you have the following objects: test/a, test/b, test/c, and test/d. If you specify test/b as the marker, test/c and test/d are returned.

+

Restrictions:

+

This parameter is only available for listing objects with a single version.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

maxKeys

+

int

+

No

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order.

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is beyond this range, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

String

+

No

+

Explanation:

+

Object names are grouped by this parameter, which is often used with Prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix. If only delimiter is set to d, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix, and bbcde is grouped separately into another CommonPrefixes with bbcd as the prefix.

+

For a PFS, if this parameter is not specified, all the contents in the current directory are recursively listed by default, and subdirectories are also listed. In big data scenarios, PFSs usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the contents in the current directory but exclude the contents in subdirectories, thereby accelerating the listing.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectListing

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

String

+

Explanation:

+

Object name prefix.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If this parameter is left blank and there are no other filtering criteria, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

objectSummaries

+

List<ObsObject>

+

Explanation:

+

List of objects in the bucket. For details, see Table 4.

+

commonPrefixes

+

List<String>

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

truncated

+

boolean

+

Explanation:

+

Whether all objects are returned in the response. A maximum of 1,000 objects can be listed at a time. If the number of objects is greater than 1,000, the objects beyond 1,000 cannot be returned.

+

Value range:

+

true: Not all objects are returned.

+

false: All objects are returned.

+

Default value:

+

None

+

marker

+

String

+

Explanation:

+

Where in the bucket the listing starts from. All objects following the object specified by this parameter are listed in alphabetical order by object name. Assume you have the following objects: test/a, test/b, test/c, and test/d. If you specify test/b as the marker, test/c and test/d are returned.

+

Restrictions:

+

This parameter is only available for listing objects with a single version.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

maxKeys

+

int

+

Explanation:

+

The maximum number of objects returned in the response in alphabetical order.

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is beyond this range, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

String

+

Explanation:

+

Object names are grouped by this parameter, which is often used with Prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix. If only delimiter is set to d, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix, and bbcde is grouped separately into another CommonPrefixes with bbcd as the prefix.

+

For a PFS, if this parameter is not specified, all the contents in the current directory are recursively listed by default, and subdirectories are also listed. In big data scenarios, PFSs usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the contents in the current directory but exclude the contents in subdirectories, thereby accelerating the listing.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

nextMarker

+

String

+

Explanation:

+

Where in the bucket the next listing begins. If not all objects are returned, the response contains this parameter to mark the last object returned for the current request. You can use the value of this parameter as the value of Marker in the subsequent request to list the remaining objects.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket is located.

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ObsObject

Parameter

+

Type

+

Description

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectContent

+

InputStream

+

Explanation:

+

The data stream of the object.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Object owner. This parameter contains the domain ID and name of the object owner. For details, see Table 5.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata.

+

Value range:

+

Object metadata. For details, see Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 6 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the object data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the object must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+

Code Example: Listing Objects in a Bucket

This example lists objects in bucket examplebucket. A maximum of 1,000 objects can be returned.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Listing objects.
+            ObjectListing result = obsClient.listObjects("examplebucket");
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Object Count for Listing

This example lists a specified number of objects in bucket examplebucket. A maximum of 100 objects can be listed.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List a specified number of objects.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            // Set the number of objects to be listed to 100.
+            request.setMaxKeys(100);
+            ObjectListing result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Prefix for Listing

This example specifies a prefix to list objects in bucket examplebucket. A maximum of 100 objects can be listed.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List objects by specifying a prefix.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            // List 100 objects with the specified prefix.
+            request.setMaxKeys(100);
+            request.setPrefix("prefix");
+            ObjectListing result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Start Position for Listing

This example specifies a start position to list objects in bucket examplebucket. A maximum of 100 objects can be listed.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List objects by specifying the start position.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            // Specify that 100 objects whose names follow test in lexicographical order will be listed.
+            request.setMaxKeys(100);
+            request.setMarker("test");
+            ObjectListing result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Using Pagination to List All Objects

This example lists all objects in bucket examplebucket using pagination. A maximum of 100 objects can be listed on each page.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects005 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List all objects using pagination.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            // Set the number of objects displayed per page to 100.
+            request.setMaxKeys(100);
+            ObjectListing result;
+            do {
+                result = obsClient.listObjects(request);
+                for (ObsObject obsObject : result.getObjects()) {
+                    System.out.println("listObjects successfully");
+                    System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                    System.out.println("Owner:" + obsObject.getOwner());
+                }
+                request.setMarker(result.getNextMarker());
+            } while (result.isTruncated());
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing Objects in a Folder

There is no concept of folders in OBS. All elements stored in OBS buckets are objects. Folders are actually objects whose sizes are 0 and whose names end with a slash (/). You can set a folder name as a prefix to list objects in this folder. This example lists objects in a folder.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects006 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            //List all objects in a folder.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            // Set folder name dir/ as the prefix.
+            request.setPrefix("dir/");
+            request.setMaxKeys(100);
+            ObjectListing result;
+            do {
+                result = obsClient.listObjects(request);
+                for (ObsObject obsObject : result.getObjects()) {
+                    System.out.println("listObjects successfully");
+                    System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                    System.out.println("Owner:" + obsObject.getOwner());
+                }
+                request.setMarker(result.getNextMarker());
+            } while (result.isTruncated());
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing All Objects in a Bucket by Folder Name

This example lists all objects in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListObjectsRequest;
+import com.obs.services.model.ObjectListing;
+import com.obs.services.model.ObsObject;
+public class ListObjects007 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List all objects in the root directory.
+            ListObjectsRequest request = new ListObjectsRequest("examplebucket");
+            request.setMaxKeys(1000);
+            // Set folder isolators to slashes (/).
+            request.setDelimiter("/");
+            ObjectListing result = obsClient.listObjects(request);
+            System.out.println("Objects in the root directory:");
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("listObjects successfully");
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+            listObjectsByPrefix(obsClient, request, result);
+        } catch (ObsException e) {
+            System.out.println("listObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+
+
+
+

Code Example: Recursively Listing Objects in a Sub-folder

This example recursively lists objects in a sub-folder.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
// Recursively list objects in a sub-folder.
+    static void listObjectsByPrefix(ObsClient obsClient, ListObjectsRequest request, ObjectListing result)
+            throws ObsException {
+        for (String prefix : result.getCommonPrefixes()) {
+            System.out.println("Objects in folder [" + prefix + "]:");
+            request.setPrefix(prefix);
+            result = obsClient.listObjects(request);
+            for (ObsObject obsObject : result.getObjects()) {
+                System.out.println("ObjectKey:" + obsObject.getObjectKey());
+                System.out.println("Owner:" + obsObject.getOwner());
+            }
+            listObjectsByPrefix(obsClient, request, result);
+        }
+    }
+}
+
+
+
+
  • The sample code does not apply to scenarios where the number of objects in a folder exceeds 1,000.
  • Since all folder names end with a slash (/) and the objects and sub-folders to list are under the folder, delimiter is always a slash (/).
  • In the returned result of each recursion, ObjectListing.getObjects includes the objects under the folder, and ObjectListing.getCommonPrefixes includes the sub-folders under the folder.
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0804.html b/docs/obs_3rd_party/java_sdk/obs_21_0804.html new file mode 100644 index 000000000..ff67640e6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0804.html @@ -0,0 +1,262 @@ + + +

Deleting an Object

+

Function

This API deletes objects from a specific bucket.

+
+

Restrictions

  • To delete an object, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or DeleteObject in a bucket policy).
  • If versioning is not enabled for a bucket, deleted objects cannot be recovered.
+
+

Method

obsClient.deleteObject(DeleteObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

DeleteObjectRequest

+

Yes

+

Explanation:

+

Request parameters for deleting an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 DeleteObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 DeleteObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

deleteMarker

+

boolean

+

Explanation:

+

Whether the deleted object is a delete marker.

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes object objectname from bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete the object.
+            obsClient.deleteObject("examplebucket", "objectname");
+            System.out.println("deleteObject successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0805.html b/docs/obs_3rd_party/java_sdk/obs_21_0805.html new file mode 100644 index 000000000..22820c913 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0805.html @@ -0,0 +1,1576 @@ + + +

Copying an Object

+

Function

This API copies an object stored in OBS to another path, with a copy created during the process. You can create a copy of an object up to 5 GB in a single operation.

+
+

Restrictions

  • To copy an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • You must have the read permission on the source object.
  • The object copy request carries the information about the source bucket and object to be copied in the header field. The message body cannot be carried.
  • Cross-bucket replication in the same region is supported, but cross-region replication is not supported.
  • An object copy can be up to 5 GB in size. If the source object exceeds 5 GB, you can only perform a multipart copy.
  • If the source object is in the Cold storage class, you must restore it first.
+
+

Method

obsClient.copyObject(CopyObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

CopyObjectRequest

+

Yes

+

Explanation:

+

Request parameters for copying an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CopyObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Target bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Target object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 3.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 4.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL specified for the object. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 8 for the available options.
  • To use a user-defined ACL, see Table 9 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+

successRedirectLocation

+

String

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected.

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, the Location header is the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

sourceBucketName

+

String

+

Yes

+

Explanation:

+

Name of the source bucket.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

sourceObjectKey

+

String

+

Yes

+

Explanation:

+

Source object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

newObjectMetadata

+

ObjectMetadata

+

No

+

Explanation:

+

User-defined metadata of the target object. For details, see Table 16.

+

Restrictions:

+

replaceMetadata must be used together with newObjectMetadata.

+

Default value:

+

None

+

replaceMetadata

+

boolean

+

No

+

Explanation:

+

Whether to rewrite the metadata of the source object.

+

Restrictions:

+

replaceMetadata must be used together with newObjectMetadata.

+

Value range:

+

true: The metadata of the source object is rewritten.

+

false: The metadata of the source object is not rewritten.

+

Default value:

+

None

+

ifModifiedSince

+

java.util.Date

+

No

+

Explanation:

+

The source object is copied if it has been modified since the specified time; otherwise, an exception is thrown.

+

Restrictions:

+
  • If the object copy request includes ifUnmodifiedSince, ifMatchTag, ifModifiedSince, or ifNoneMatchTag, and the specified condition is not met, the copy will fail and an exception will be thrown with HTTP status code 412 precondition failed returned.
  • ifModifiedSince and ifNoneMatchTag can be used together. So do ifUnmodifiedSince and ifMatchTag.
+

Default value:

+

None

+

ifUnmodifiedSince

+

java.util.Date

+

No

+

Explanation:

+

If the source object has not been modified since the specified time, it is copied. Otherwise, an exception is thrown.

+

Restrictions:

+
  • If the object copy request includes ifUnmodifiedSince, ifMatchTag, ifModifiedSince, or ifNoneMatchTag, and the specified condition is not met, the copy will fail and an exception will be thrown with HTTP status code 412 precondition failed returned.
  • ifModifiedSince and ifNoneMatchTag can be used together. So do ifUnmodifiedSince and ifMatchTag.
+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the source object is the same as the preset ETag, the object is returned. Otherwise, an error is returned. The ETag of the source object is the MD5 value of it.

+

Restrictions:

+
  • If the object copy request includes ifUnmodifiedSince, ifMatchTag, ifModifiedSince, or ifNoneMatchTag, and the specified condition is not met, the copy will fail and an exception will be thrown with HTTP status code 412 precondition failed returned.
  • ifModifiedSince and ifNoneMatchTag can be used together. So do ifUnmodifiedSince and ifMatchTag.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the source object is different from the preset ETag, the object is returned. Otherwise, an error is returned. The ETag of the source object is the MD5 value of it.

+

Restrictions:

+
  • If the object copy request includes ifUnmodifiedSince, ifMatchTag, ifModifiedSince, or ifNoneMatchTag, and the specified condition is not met, the copy will fail and an exception will be thrown with HTTP status code 412 precondition failed returned.
  • ifModifiedSince and ifNoneMatchTag can be used together. So do ifUnmodifiedSince and ifMatchTag.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Source object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseCHeaderSource

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header used for decrypting the source object. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 5.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 7.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 6 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 7 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 8 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 9 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 10.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 11.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 11 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 13.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 12.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 13 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 14.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 15.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 14 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 15 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 16 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 17.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 17 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 18 CopyObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

lastModified

+

java.util.Date

+

Explanation:

+

Last time the target object was modified.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of the target object. Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Version ID of the target object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

copySourceVersionId

+

String

+

Explanation:

+

Version ID of the source object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the target object.

+

Value range:

+

See Table 17.

+

Default value:

+

None

+
+
+
+

Code Example: Copying an Object

This example copies object sourceobjectname from bucket sourcebucketname to bucket destbucketname as object destobjectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CopyObjectResult;
+public class CopyObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Copy an object.
+            CopyObjectResult result =
+                    obsClient.copyObject("sourcebucketname", "sourceobjectname", "destbucketname", "destobjectname");
+            System.out.println("copyObject successfully");
+            System.out.println("StatusCode:" + result.getStatusCode());
+            System.out.println("Etag:" + result.getEtag());
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Copying an Object and Rewriting Object Attributes

This example rewrites object attributes when object sourceobjectname is copied from bucket sourcebucketname to bucket destbucketname as object destobjectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CopyObjectRequest;
+import com.obs.services.model.CopyObjectResult;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.StorageClassEnum;
+public class CopyObject002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Rewrite object attributes when copying an object.
+            CopyObjectRequest request = new CopyObjectRequest("sourcebucketname", "sourceobjectname", "destbucketname", "destobjectname");
+            // Rewrite object attributes.
+            request.setReplaceMetadata(true); 
+            HashMap<String, String> userHeaders = new HashMap<>();
+            userHeaders.put("Content-Type","image/jpeg");
+            request.setUserHeaders(userHeaders);
+            CopyObjectResult result = obsClient.copyObject(request);
+            System.out.println("copyObject successfully");
+            System.out.println("Etag:" + result.getEtag());
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Copying an Object Conditionally

This example specifies conditions when object sourceobjectname is copied from bucket sourcebucketname to bucket destbucketname as object destobjectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CopyObjectRequest;
+import com.obs.services.model.CopyObjectResult;
+import java.text.SimpleDateFormat;
+public class CopyObject003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set conditions for the copy.
+            CopyObjectRequest request =
+                    new CopyObjectRequest("sourcebucketname", "sourceobjectname", "destbucketname", "destobjectname");
+            request.setIfModifiedSince(new SimpleDateFormat("yyyy-MM-dd").parse("2016-01-01"));
+            request.setIfNoneMatchTag("none-match-etag");
+            CopyObjectResult result = obsClient.copyObject(request);
+            System.out.println("copyObject successfully");
+            System.out.println("Etag:" + result.getEtag());
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Copying an Object and Rewriting its ACL

This example rewrites the object ACL when object sourceobjectname is copied from bucket sourcebucketname to bucket destbucketname as object destobjectname.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.CopyObjectRequest;
+import com.obs.services.model.CopyObjectResult;
+public class CopyObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Rewrite the object ACL when copying the object.
+            CopyObjectRequest request =
+                    new CopyObjectRequest("sourcebucketname", "sourceobjectname", "destbucketname", "destobjectname");
+            // Rewrite the object ACL to Private.
+            request.setAcl(AccessControlList.REST_CANNED_PRIVATE);
+            CopyObjectResult result = obsClient.copyObject(request);
+            System.out.println("copyObject successfully");
+            System.out.println("Etag:" + result.getEtag());
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0806.html b/docs/obs_3rd_party/java_sdk/obs_21_0806.html new file mode 100644 index 000000000..2a6d18077 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0806.html @@ -0,0 +1,777 @@ + + +

Configuring Object Metadata

+

Function

Object metadata is a set of name-value pairs that describe the object and is used for object management.

+

Currently, only the system-defined metadata is supported.

+

There are two kinds of metadata: system-controlled metadata and user-controlled metadata. The kind of metadata like Last-Modified is controlled by the system and cannot be modified. However, the kind of metadata configured for objects such as ContentLanguage can be modified by calling APIs.

+

This API sends a HEAD request to configure the metadata of an object in a specified bucket.

+
+

Restrictions

  • To configure object metadata, you must be the bucket owner or have the required permission (obs:object:ModifyObjectMetaData in IAM or ModifyObjectMetaData in a bucket policy).
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • Currently, metadata names only support ASCII characters. Non-ASCII characters must be Base64-encoded.
  • If versioning is enabled for a bucket, you can set metadata for objects of the latest version, but cannot set metadata for noncurrent objects.
  • You cannot set metadata for Cold objects.
  • If a folder or directory is an actual object in an object bucket, their metadata can be modified. If a directory is a simulated directory, for example, test/ in the test/test1.txt object, the metadata of this simulated directory cannot be modified.
+
+

Method

obsClient.setObjectMetadata(SetObjectMetadataRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetObjectMetadataRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining object metadata. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 SetObjectMetadataRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of the object.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

removeUnset

+

boolean

+

No

+

Explanation:

+

Whether to delete the previously configured metadata if the request is successful.

+

Value range:

+

true: If the API is successfully invoked, the previous metadata will be deleted. Standard metadata is not affected. For user-defined metadata, only the new metadata is retained.

+

false: The previous metadata will not be deleted even if the API is successfully invoked. Standard metadata is not affected. For user-defined metadata, only the new metadata is retained.

+

Default value:

+

false

+

userMetadata

+

Map<String, String>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key and value indicate the name and value of the user-defined metadata respectively. After the metadata is defined, when you later download the object or query its metadata, the user-defined metadata is returned in the response.

+

Restrictions:

+
  • The user-defined metadata cannot exceed 8 KB in total. To measure the size, calculate the sum of bytes of all UTF-8 encoded keys and values.
  • The user-defined metadata keys are case insensitive, because OBS converts the uppercase keys to lowercase for storage. However, the metadata values are case sensitive.
  • Both user-defined metadata keys and their values must conform to US-ASCII standards. If non-ASCII or unrecognizable characters are necessary, they must be encoded and decoded in URL or Base64 on the client, because the server side does not perform any decoding.
+

Default value:

+

None

+

userHeaders

+

HashMap<String, String>

+

No

+

Explanation:

+

User header list. In HashMap, the String key and value indicate the name and value of the user header field respectively. The SDK does not process the userHeaders and instead transparently transmits it to the server for later use.

+

Default value:

+

None

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

It specifies the metadata returned when the object is downloaded. For details, see Table 4.

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

OBS obtains the specified value from the header and stores it in the object metadata WebsiteRedirectLocation.

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 3 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class.

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

It specifies the content encoding format when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the object data. It is provided for the OBS server to verify data integrity.

+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Object storage class. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 3.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata.

+

Default value:

+

None

+

statusCode

+

int

+

This parameter is automatically set in the response.

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

This parameter is automatically set in the response.

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Configuring Metadata for the Object

This example configures metadata for object objectname by specifying the user-defined metadata and using userHeaders that are transparently transmitted.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.SetObjectMetadataRequest;
+import java.util.HashMap;
+public class SetObjectMetadata001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Configure metadata for the object.
+            SetObjectMetadataRequest request = new SetObjectMetadataRequest("examplebucket", "objectname");
+            // Standard HTTP headers of an object
+            request.setContentType("ContentType");
+            request.setExpires("Expires");
+            // During the user-defined metadata setting, the SDK automatically adds x-obs-meta-.
+            request.addUserMetadata("property1", "property-value1");
+            HashMap<String, String> userHeaders = new HashMap<>();
+            // userHeaders set by the SDK are transparently transmitted. They are not processed so they can be used more flexibly later. If a userHeader needs to be displayed as user-defined metadata on the server, add x-obs-meta- before the userHeader for the server to identify.
+            userHeaders.put("property2", "property-value2");
+            userHeaders.put("x-obs-meta-property3", "property-value3");
+            request.setUserHeaders(userHeaders);
+            ObjectMetadata metadata = obsClient.setObjectMetadata(request);
+            System.out.println("setObjectMetadata successfully");
+            System.out.println("UserMetadata:" + metadata.getUserMetadata("property1"));
+        } catch (ObsException e) {
+            System.out.println("setObjectMetadata failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setObjectMetadata failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

After you run the sample code above and configure the user-defined metadata property1 and user headers property2 and x-obs-meta-property3, the HTTP header in the packet capture is as follows:

+

+
+

Code Example: Deleting Metadata for the Object

If you want to delete some metadata by calling the API for setting object metadata, configure the metadata to be retained and set SetObjectMetadataRequest.setRemoveUnset to true. Then, once the API is called, the data whose metadata is not configured will be deleted. Therefore, exercise caution when using SetObjectMetadataRequest.setRemoveUnset(true).

+

This example deletes the user-defined metadata of object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.SetObjectMetadataRequest;
+import java.util.HashMap;
+public class SetObjectMetadata002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            SetObjectMetadataRequest request = new SetObjectMetadataRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setRemoveUnset(true);
+            HashMap<String, String> userHeaders = new HashMap<>();
+            // After request.setRemoveUnset is set to true, the server saves metadata property1 and deletes the user-defined metadata saved before.
+            userHeaders.put("x-obs-meta-property1", "property-value1");
+            request.setUserHeaders(userHeaders);
+            obsClient.setObjectMetadata(request);
+            System.out.println("setObjectMetadata successfully");
+        } catch (ObsException e) {
+            System.out.println("setObjectMetadata failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setObjectMetadata failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0807.html b/docs/obs_3rd_party/java_sdk/obs_21_0807.html new file mode 100644 index 000000000..e04c336f1 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0807.html @@ -0,0 +1,353 @@ + + +

Checking Whether an Object Exists

+

Function

This API checks whether an object exists. If the returned HTTP status code is 200, the object exists. If the returned HTTP status code is 404, the object or bucket does not exist.

+
+

Restrictions

  • To check whether an object exists, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
+
+

Method

doesObjectExist(final GetObjectMetadataRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectMetadataRequest

+

Yes

+

Explanation:

+

Request parameters. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectMetadataRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

userHeaders

+

HashMap<String, String>

+

No

+

Explanation:

+

User header list. In HashMap, the String key and value indicate the name and value of the user header field respectively. The SDK does not process the userHeaders and instead transparently transmits it to the server for later use.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to encode and decode HTTP headers.

+

Value range:

+

true: HTTP headers are encoded and decoded.

+

false: HTTP headers are not encoded or decoded.

+

Default value:

+

true

+

sseHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption headers. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 4.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + +
Table 5 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+
+

Responses

+
+ + + + + + + + + +
Table 6 Response headers

Method

+

Return Value Type

+

Description

+

doesObjectExist(final GetObjectMetadataRequest request)

+

boolean

+

Whether the object exists in the bucket.

+
+
+
+

Code Examples

This example checks whether object objectname exists in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DoesObjectExist001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Check whether the specified object exists.
+            System.out.println(obsClient.doesObjectExist("examplebucket", "objectname") ? "exists!" : "does not exist!");
+            System.out.println("doesObjectExist successfully");
+        } catch (ObsException e) {
+            System.out.println("doesObjectExist failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("doesObjectExist failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0808.html b/docs/obs_3rd_party/java_sdk/obs_21_0808.html new file mode 100644 index 000000000..effb52a63 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0808.html @@ -0,0 +1,519 @@ + + +

Obtaining an Object ACL

+

Function

Access control lists (ACLs) allow resource owners to grant other accounts the permissions to access resources. By default, only the resource owner has full control over resources when a bucket or object is created. That is, the bucket creator has full control over the bucket, and the object uploader has full control over the object. Other accounts do not have the permissions to access resources. If resource owners want to grant other accounts the read and write permissions on resources, they can use ACLs. ACLs grant permissions to accounts. After an account is granted permissions, both the account and its IAM users can access the resources. If an object is encrypted with SSE-KMS, the ACL configured for it is not in effect in the cross-tenant case.

+

+

This API obtains the ACL of an object in a specified bucket.

+
+

Restrictions

  • To obtain an object ACL, you must be the bucket owner or have the required permission (obs:object:GetObjectAcl in IAM or GetObjectAcl in a bucket policy).
+
+

Method

obsClient.getObjectAcl(GetObjectAclRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectAclRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining an object ACL. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectAclRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 AccessControlList

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Object owner. For details, see Table 8.

+

grants

+

Set<GrantAndPermission>

+

Explanation:

+

Grantee information. For details, see Table 4.

+

delivered

+

boolean

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 5.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 6.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 7 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 8 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Code Examples

This example returns the ACL information of object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+public class GetObjectAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the object ACL.
+            AccessControlList acl = obsClient.getObjectAcl("examplebucket", "objectname");
+            System.out.println("getObjectAcl successfully");
+            System.out.println(acl);
+        } catch (ObsException e) {
+            System.out.println("getObjectAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0809.html b/docs/obs_3rd_party/java_sdk/obs_21_0809.html new file mode 100644 index 000000000..d182c97a7 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0809.html @@ -0,0 +1,635 @@ + + +

Batch Deleting Objects

+

Function

This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.

+

In a batch delete operation, OBS concurrently deletes the specified objects and returns the deletion result of each object.

+
+

Restrictions

  • To delete objects in a batch, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or DeleteObject in a bucket policy).
  • If versioning is not enabled for a bucket, deleted objects cannot be recovered.
  • A maximum of 1,000 objects can be deleted at a time. If you send a request for deleting more than 1,000 objects, OBS returns an error message.
  • After concurrent tasks are assigned, if an internal error occurs during cyclic deletion of multiple objects, an object may be deleted in the index data but still exist in the metadata.
+
+

Method

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

deleteRequest

+

DeleteObjectsRequest

+

Yes

+

Explanation:

+

Request parameters for deleting objects in batches. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 DeleteObjectsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

keyAndVersions

+

List<KeyAndVersion>

+

Yes

+

Explanation:

+

List of objects to be deleted. For details, see Table 3.

+

quiet

+

boolean

+

No

+

Explanation:

+

Response mode to the request for deleting objects in a batch.

+

Value range:

+
  • false: The detailed mode. Results of both successful and failed deletions are returned.
  • true: The quiet mode. Only results of failed deletions are returned.
+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 KeyAndVersion

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 DeleteObjectsResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

deletedObjectResults

+

List<DeleteObjectResult>

+

Explanation:

+

Response results of the request for deleting objects in a batch. For details, see Table 5.

+

errorResults

+

List<ErrorResult>

+

Explanation:

+

List of objects that fail to be deleted. For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 DeleteObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

deleteMarker

+

boolean

+

Explanation:

+

Whether the deleted object is a delete marker.

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 ErrorResult

Parameter

+

Type

+

Description

+

versionId

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

errorCode

+

String

+

Explanation:

+

Error code for the failed deletion.

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

message

+

String

+

Explanation:

+

Error message for the failed deletion.

+
+
+
+

Code Examples

This example deletes all objects whose names start with exampleObjectPrefix in bucket example-bucket in a batch. Note that if exampleObjectPrefix is left blank, all objects in the bucket will be deleted.

+
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.DeleteObjectsRequest;
+import com.obs.services.model.DeleteObjectsResult;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+import java.util.Map;
+
+public class DeleteObjects002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+
+        // Create a single instance of ObsClient.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            String exampleBucket = "example-bucket";
+            String exampleObjectPrefix = "exampleObjectPrefix";
+            // Batch delete the objects.
+            ListVersionsRequest request = new ListVersionsRequest(exampleBucket);
+            // Delete 100 objects at a time.
+            request.setMaxKeys(100);
+            request.setPrefix(exampleObjectPrefix);
+            ListVersionsResult result;
+            do {
+                result = obsClient.listVersions(request);
+                DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(exampleBucket);
+                // deleteRequest.setQuiet(true);
+                // This example uses the verbose mode. To use the quiet mode, add this line of code.
+                for (VersionOrDeleteMarker v : result.getVersions()) {
+                    // Obtain object names and version IDs.
+                    deleteRequest.addKeyAndVersion(v.getKey(), v.getVersionId());
+                }
+                if(deleteRequest.getKeyAndVersions().length > 0){
+                    DeleteObjectsResult deleteResult = obsClient.deleteObjects(deleteRequest);
+                    // Print the deleted objects.
+                    System.out.println("DeletedObjectResults:"+ deleteResult.getDeletedObjectResults());
+                    // Print the objects that were not deleted.
+                    System.out.println("ErrorResults:"+ deleteResult.getErrorResults());
+                }else{
+                    System.out.println("No object to delete");
+                }
+                request.setKeyMarker(result.getNextKeyMarker());
+                // If versioning is not enabled, do not configure VersionIdMarker.
+                request.setVersionIdMarker(result.getNextVersionIdMarker());
+            } while (result.isTruncated());
+            System.out.println("deleteObjects successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            Map<String, String> headers = e.getResponseHeaders();// Check Map entries and print all headers associated with the error.
+            if(headers != null){
+                for (Map.Entry<String, String> header : headers.entrySet()) {
+                    if(header.getKey().contains("error")){
+                        System.out.println(header.getKey()+":"+header.getValue());
+                    }
+                }
+            }
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObjects failed");
+            // Print other error details.
+            e.printStackTrace();
+        }
+    }
+}
+

This example batch deletes all objects in bucket examplebucket. Exercise caution when performing this operation.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.DeleteObjectsRequest;
+import com.obs.services.model.DeleteObjectsResult;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class DeleteObjects001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Batch delete the objects.
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket");
+            // Delete 100 objects at a time.
+            request.setMaxKeys(100);
+            ListVersionsResult result;
+            do {
+                result = obsClient.listVersions(request);
+                DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest("examplebucket");
+                // deleteRequest.setQuiet(true); // This example uses the verbose mode. To use the quiet mode, add this line of code.
+                for (VersionOrDeleteMarker v : result.getVersions()) {
+                    // Obtain objects' names and version IDs.
+                    deleteRequest.addKeyAndVersion(v.getKey(), v.getVersionId());
+                }
+                if(deleteRequest.getKeyAndVersions().length > 0){
+                    DeleteObjectsResult deleteResult = obsClient.deleteObjects(deleteRequest);
+                    // Print the deleted objects.
+                    System.out.println("DeletedObjectResults:"+ deleteResult.getDeletedObjectResults());
+                    // Print the objects that were not deleted.
+                    System.out.println("ErrorResults:"+ deleteResult.getErrorResults());
+                }else{
+                    System.out.println("No object to delete");
+                }
+                request.setKeyMarker(result.getNextKeyMarker());
+                // If versioning is not enabled, do not configure VersionIdMarker.
+                request.setVersionIdMarker(result.getNextVersionIdMarker());
+            } while (result.isTruncated());
+            System.out.println("deleteObjects successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

This example deletes all objects in the test folder in the examplebucket bucket with versioning disabled.

+
import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.*;
+import java.io.IOException;
+import java.util.Map;
+
+public class Delete_Objects_test {
+    public static void main(String[] args) throws IOException {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        // String endPoint = System.getenv("ENDPOINT");
+
+        // Create a single instance of ObsClient.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        try {
+            String exampleBucket = "examplebucket";
+            String exampleObjectPrefix = "test/";
+            ListObjectsRequest listObjectsRequest = new ListObjectsRequest(exampleBucket);
+            listObjectsRequest.setMaxKeys(100);
+            listObjectsRequest.setPrefix(exampleObjectPrefix);
+            ObjectListing objectListing;
+
+            do {
+                objectListing = obsClient.listObjects(listObjectsRequest);
+                DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(exampleBucket);
+                // This example uses the verbose mode. To use the quiet mode, add this line of code.
+                deleteRequest.setQuiet(true);
+                for (ObsObject object : objectListing.getObjects()) {
+                    deleteRequest.addKeyAndVersion(object.getObjectKey(), null);
+                }
+
+                if (deleteRequest.getKeyAndVersions().length > 0) {
+                    DeleteObjectsResult deleteResult = obsClient.deleteObjects(deleteRequest);
+                    // Print the deleted objects.
+                    System.out.println("DeletedObjectResults:" + deleteResult.getDeletedObjectResults());
+                    // Print the objects that were not deleted.
+                    System.out.println("ErrorResults:" + deleteResult.getErrorResults());
+                } else {
+                    System.out.println("No object to delete");
+                }
+                listObjectsRequest.setMarker(objectListing.getNextMarker());
+            } while (objectListing.isTruncated());
+            System.out.println("deleteObjects successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            Map<String, String> headers = e.getResponseHeaders();
+            // Check all Map entries and print all headers associated with the error.
+            if (headers != null) {
+                for (Map.Entry<String, String> header : headers.entrySet()) {
+                    if (header.getKey().contains("error")) {
+                        System.out.println(header.getKey() + ":" + header.getValue());
+                    }
+                }
+            }
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObjects failed");
+            // Print other error details.
+            e.printStackTrace();
+        }
+
+}
+}
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0810.html b/docs/obs_3rd_party/java_sdk/obs_21_0810.html new file mode 100644 index 000000000..d91e0a42e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0810.html @@ -0,0 +1,627 @@ + + +

Copying an Object - Multipart

+

Function

This API allows you to upload a part by copying an object or part of this object.

+

You can call ObsClient.copyPart to copy parts.

+
+

Restrictions

  • To copy an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • You must have the read permission on the source object.
  • The object copy request carries the information about the source bucket and object to be copied in the header field. The message body cannot be carried.
  • Cross-bucket replication in the same region is supported, but cross-region replication is not supported.
  • If the source object is in the Cold storage class, you must restore it first.
+
+

Method

obsClient.copyPart(CopyPartRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

CopyPartRequest

+

Yes

+

Explanation:

+

Request parameters for copying an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CopyPartRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

sourceBucketName

+

String

+

Yes

+

Explanation:

+

Name of the source bucket.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

sourceObjectKey

+

String

+

Yes

+

Explanation:

+

Source object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

destinationBucketName

+

String

+

Yes

+

Explanation:

+

Target bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

destinationObjectKey

+

String

+

Yes

+

Explanation:

+

Target object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

byteRangeStart

+

Long

+

No

+

Explanation:

+

Start position for the multipart copy

+

Value range:

+

A non-negative integer, in bytes.

+

Default value:

+

0

+

byteRangeEnd

+

Long

+

No

+

Explanation:

+

End position for the multipart copy

+

Restrictions:

+

The value must be greater than that of RangeStart. The upper limit of the value is the object length minus 1, in bytes.

+

Value range:

+

A non-negative integer, in bytes.

+

Default value:

+

None

+

sseCHeaderSource

+

SseCHeader

+

No

+

Explanation:

+

Server-side header used for decrypting the source object. For details, see Table 3.

+

sseCHeaderDestination

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 3.

+

Restrictions:

+

If the object uploaded to a server is encrypted with the key provided by the client, the key must also be provided in the message for downloading the object.

+

versionId

+

String

+

No

+

Explanation:

+

Version ID of the source object, for example, G001117FCE89978B0000401205D5DC9A. If the source object has multiple versions, you can specify this parameter.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

partNumber

+

int

+

Yes

+

Explanation:

+

Part number.

+

Value range:

+

An integer ranging from 1 to 10000

+

Default value:

+

None

+

uploadId

+

String

+

Yes

+

Explanation:

+

Multipart upload ID, for example, 000001648453845DBB78F2340DD460D8.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 4.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 4 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + +
Table 5 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 CopyPartResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

partNumber

+

int

+

Explanation:

+

Part number.

+

Value range:

+

An integer ranging from 1 to 10000.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

lastModified

+

java.util.Date

+

Explanation:

+

Last time the target part was modified.

+

Default value:

+

None

+
+
+
+

Code Examples

This example copies object sourceobjectname in parts from bucket sourcebucketname to bucket destbucketname as object destobjectname.

+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CompleteMultipartUploadRequest;
+import com.obs.services.model.CopyPartRequest;
+import com.obs.services.model.CopyPartResult;
+import com.obs.services.model.InitiateMultipartUploadRequest;
+import com.obs.services.model.InitiateMultipartUploadResult;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.PartEtag;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+public class CopyPart001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Copy parts.
+            final String destBucketName = "destbucketname";
+            final String destObjectKey = "destobjectname";
+            final String sourceBucketName = "sourcebucketname";
+            final String sourceObjectKey = "sourceobjectname";
+            // Initialize the thread pool.
+            ExecutorService executorService = Executors.newFixedThreadPool(20);
+            // Initiate a multipart upload.
+            InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest(destBucketName, destObjectKey);
+            InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request);
+            final String uploadId = result.getUploadId();
+            System.out.println("uploadId:" + uploadId + "\n");
+            // Obtain information about the large object.
+            ObjectMetadata metadata = obsClient.getObjectMetadata(sourceBucketName, sourceObjectKey);
+            // Set the part size to 100 MB.
+            long partSize = 100 * 1024 * 1024L;
+            long objectSize = metadata.getContentLength();
+            // Calculate the number of parts to be copied.
+            long partCount = objectSize % partSize == 0 ? objectSize / partSize : objectSize / partSize + 1;
+            final List<PartEtag> partEtags = Collections.synchronizedList(new ArrayList<>());
+            // Start copying parts concurrently.
+            for (int i = 0; i < partCount; i++) {
+                // Start position for copying parts
+                final long rangeStart = i * partSize;
+                // End position for copying parts
+                final long rangeEnd = (i + 1 == partCount) ? objectSize - 1 : rangeStart + partSize - 1;
+                // Set the part number.
+                final int partNumber = i + 1;
+                executorService.execute(
+                        new Runnable() {
+                            @Override
+                            public void run() {
+                                CopyPartRequest request = new CopyPartRequest();
+                                request.setUploadId(uploadId);
+                                request.setSourceBucketName(sourceBucketName);
+                                request.setSourceObjectKey(sourceObjectKey);
+                                request.setDestinationBucketName(destBucketName);
+                                request.setDestinationObjectKey(destObjectKey);
+                                request.setByteRangeStart(rangeStart);
+                                request.setByteRangeEnd(rangeEnd);
+                                request.setPartNumber(partNumber);
+                                CopyPartResult result;
+                                try {
+                                    result = obsClient.copyPart(request);
+                                    System.out.println("Part#" + partNumber + " done\n");
+                                    partEtags.add(new PartEtag(result.getEtag(), result.getPartNumber()));
+                                } catch (ObsException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        });
+            }
+            // Wait until the copy is complete.
+            executorService.shutdown();
+            while (!executorService.isTerminated()) {
+                try {
+                    executorService.awaitTermination(5, TimeUnit.SECONDS);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+            // Assemble parts.
+            CompleteMultipartUploadRequest completeMultipartUploadRequest =
+                    new CompleteMultipartUploadRequest(destBucketName, destObjectKey, uploadId, partEtags);
+            obsClient.completeMultipartUpload(completeMultipartUploadRequest);
+            System.out.println("copyObject successfully");
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0900.html b/docs/obs_3rd_party/java_sdk/obs_21_0900.html new file mode 100644 index 000000000..19a2baa4c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0900.html @@ -0,0 +1,11 @@ + + +

Temporarily Authorized Access

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_0901.html b/docs/obs_3rd_party/java_sdk/obs_21_0901.html new file mode 100644 index 000000000..d6bb92cba --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_0901.html @@ -0,0 +1,2671 @@ + + +

Accessing OBS Using a Signed URL

+

Function

ObsClient allows you to create a URL with Query parameters that carry authentication information by specifying the AK and SK, HTTP method, and request parameters. You can provide this URL to other users for them to make a temporary access. When generating a URL, you need to specify the validity period of the URL to restrict the access duration of visitors.

+

If you want to grant other users the permission to perform operations on buckets or objects (for example, upload or download objects), you need to generate a URL for the corresponding request (for example, a URL with the PUT request for uploading an object) and provide the URL to other users.

+
If a CORS or signature mismatch error occurs, refer to the following steps to troubleshoot the issue:
  1. If CORS is not configured, you need to configure CORS rules on OBS Console.
  2. If the signatures do not match, check whether signature parameters are correct. For example, during an object upload, the backend uses Content-Type to calculate the signature and generate an authorized URL, but if Content-Type is not set or is set to an incorrect value when the frontend uses the authorized URL, a CORS error occurs. To avoid this issue, ensure that Content-Type fields are the same at the frontend and backend.
  3. A CDN acceleration domain name cannot be used to create a signed URL.
+
+
+

The following table lists operations that can be performed through a signed URL.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 HttpMethodEnum & SpecialParamEnum

Operation

+

HTTP Request Method (Value in OBS SDK for Java)

+

Special Operator (Value in OBS SDK for Java)

+

Bucket Name Required (Yes/No)

+

Object Name Required (Yes/No)

+

Create Bucket

+

HttpMethodEnum.PUT

+

N/A

+

Yes

+

No

+

List Buckets

+

HttpMethodEnum.GET

+

N/A

+

No

+

No

+

Delete Bucket

+

HttpMethodEnum.DELETE

+

N/A

+

Yes

+

No

+

List Objects

+

HttpMethodEnum.GET

+

N/A

+

Yes

+

No

+

List Object Versions

+

HttpMethodEnum.GET

+

SpecialParamEnum.VERSIONS

+

Yes

+

No

+

List Multipart Uploads

+

HttpMethodEnum.GET

+

SpecialParamEnum.UPLOADS

+

Yes

+

No

+

Get Bucket Metadata

+

HttpMethodEnum.HEAD

+

N/A

+

Yes

+

No

+

Get Bucket Location

+

HttpMethodEnum.GET

+

SpecialParamEnum.LOCATION

+

Yes

+

No

+

Get Bucket Storageinfo

+

HttpMethodEnum.GET

+

SpecialParamEnum.STORAGEINFO

+

Yes

+

No

+

Set Bucket Quota

+

HttpMethodEnum.PUT

+

SpecialParamEnum.QUOTA

+

Yes

+

No

+

Get Bucket Quota

+

HttpMethodEnum.GET

+

SpecialParamEnum.QUOTA

+

Yes

+

No

+

Set Bucket Storage Policy

+

HttpMethodEnum.PUT

+

SpecialParamEnum.STORAGEPOLICY

+

Yes

+

No

+

Get Bucket Storage Policy

+

HttpMethodEnum.GET

+

SpecialParamEnum.STORAGEPOLICY

+

Yes

+

No

+

Configure Bucket ACL

+

HttpMethodEnum.PUT

+

SpecialParamEnum.ACL

+

Yes

+

No

+

Obtain Bucket ACL

+

HttpMethodEnum.GET

+

SpecialParamEnum.ACL

+

Yes

+

No

+

Set Bucket Logging

+

HttpMethodEnum.PUT

+

SpecialParamEnum.LOGGING

+

Yes

+

No

+

Get Bucket Logging

+

HttpMethodEnum.GET

+

SpecialParamEnum.LOGGING

+

Yes

+

No

+

Set Bucket Policy

+

HttpMethodEnum.PUT

+

SpecialParamEnum.POLICY

+

Yes

+

No

+

Get Bucket Policy

+

HttpMethodEnum.GET

+

SpecialParamEnum.POLICY

+

Yes

+

No

+

Delete Bucket Policy

+

HttpMethodEnum.DELETE

+

SpecialParamEnum.POLICY

+

Yes

+

No

+

Set Lifecycle Rule

+

HttpMethodEnum.PUT

+

SpecialParamEnum.LIFECYCLE

+

Yes

+

No

+

Get Lifecycle Rule

+

HttpMethodEnum.GET

+

SpecialParamEnum.LIFECYCLE

+

Yes

+

No

+

Delete Lifecycle Rule

+

HttpMethodEnum.DELETE

+

SpecialParamEnum.LIFECYCLE

+

Yes

+

No

+

Set Website Hosting

+

HttpMethodEnum.PUT

+

SpecialParamEnum.WEBSITE

+

Yes

+

No

+

Get Website Hosting

+

HttpMethodEnum.GET

+

SpecialParamEnum.WEBSITE

+

Yes

+

No

+

Delete Website Hosting

+

HttpMethodEnum.DELETE

+

SpecialParamEnum.WEBSITE

+

Yes

+

No

+

Set Bucket Versioning

+

HttpMethodEnum.PUT

+

SpecialParamEnum.VERSIONING

+

Yes

+

No

+

Get Bucket Versioning

+

HttpMethodEnum.GET

+

SpecialParamEnum.VERSIONING

+

Yes

+

No

+

Set CORS Rule

+

HttpMethodEnum.PUT

+

SpecialParamEnum.CORS

+

Yes

+

No

+

Get CORS Rule

+

HttpMethodEnum.GET

+

SpecialParamEnum.CORS

+

Yes

+

No

+

Delete CORS Rule

+

HttpMethodEnum.DELETE

+

SpecialParamEnum.CORS

+

Yes

+

No

+

Set Bucket Tagging

+

HttpMethodEnum.PUT

+

SpecialParamEnum.TAGGING

+

Yes

+

No

+

Get Bucket Tagging

+

HttpMethodEnum.GET

+

SpecialParamEnum.TAGGING

+

Yes

+

No

+

Delete Bucket Tagging

+

HttpMethodEnum.DELETE

+

SpecialParamEnum.TAGGING

+

Yes

+

No

+

Upload Object

+

HttpMethodEnum.PUT

+

N/A

+

Yes

+

Yes

+

Append Object

+

HttpMethodEnum.POST

+

SpecialParamEnum.APPEND

+

Yes

+

Yes

+

Get Object

+

HttpMethodEnum.GET

+

N/A

+

Yes

+

Yes

+

Copy Object

+

HttpMethodEnum.PUT

+

N/A

+

Yes

+

Yes

+

Delete Object

+

HttpMethodEnum.DELETE

+

N/A

+

Yes

+

Yes

+

Delete Objects

+

HttpMethodEnum.POST

+

SpecialParamEnum.DELETE

+

Yes

+

Yes

+

Get Object Metadata

+

HttpMethodEnum.HEAD

+

N/A

+

Yes

+

Yes

+

Configure Object ACL

+

HttpMethodEnum.PUT

+

SpecialParamEnum.ACL

+

Yes

+

Yes

+

Obtain Object ACL

+

HttpMethodEnum.GET

+

SpecialParamEnum.ACL

+

Yes

+

Yes

+

Initiate Multipart Upload

+

HttpMethodEnum.POST

+

SpecialParamEnum.UPLOADS

+

Yes

+

Yes

+

Upload Part

+

HttpMethodEnum.PUT

+

N/A

+

Yes

+

Yes

+

Copy Part

+

HttpMethodEnum.PUT

+

N/A

+

Yes

+

Yes

+

List Parts

+

HttpMethodEnum.GET

+

N/A

+

Yes

+

Yes

+

Assemble Parts

+

HttpMethodEnum.POST

+

N/A

+

Yes

+

Yes

+

Delete Multipart Upload

+

HttpMethodEnum.DELETE

+

N/A

+

Yes

+

Yes

+

Restore Cold Objects

+

HttpMethodEnum.POST

+

SpecialParamEnum.RESTORE

+

Yes

+

Yes

+
+
+

To access OBS using a signed URL generated by the OBS SDK for Java, perform the following steps:

+
  1. Use ObsClient.createTemporarySignature to create a signed URL. Note that the ObsClient.createTemporarySignature function has encoded the generated URL. The browser will automatically decode the URL. You do not need to encode it again.
  2. Use an HTTP library to make an HTTP/HTTPS request to OBS.
+

Method

obsClient.createTemporarySignature(TemporarySignatureRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 2 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

TemporarySignatureRequest

+

Yes

+

Explanation:

+

Request parameters for creating a signed URL. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 TemporarySignatureRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

No

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

No

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

specialParam

+

SpecialParamEnum

+

No

+

Explanation:

+

Special parameters that may be used in the request, indicating the sub-operations.

+

Value range:

+

See Table 1.

+

Default value:

+

None

+

method

+

HttpMethodEnum

+

Yes

+

Explanation:

+

HTTP method type.

+

Value range:

+

See Table 1.

+

Default value:

+

None

+

headers

+

Map<String, String>

+

No

+

Explanation:

+

Headers in the request. In Map, the String key and value indicate the name and value of the request header respectively.

+

Default value:

+

None

+

queryParams

+

Map<String, Object>

+

No

+

Explanation:

+

Query parameters in the request. In Map, the String key indicates the name of the query parameter, and the Object value indicates the value of the query parameter.

+

Default value:

+

None

+

expires

+

long

+

Yes

+

Explanation:

+

Expiration time of the signed URL.

+

Value range:

+
  • If you use a temporary key to call the SDK API, the value of expires ranges from 0 to 86400 seconds.
  • If you use a permanent key to call the SDK API, the value of expires ranges from 0 to 630720000 seconds.
+

Default value:

+

300

+

requestDate

+

Date

+

Yes

+

Explanation:

+

Time when the request is initiated.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 4 TemporarySignatureResponse

Parameter

+

Type

+

Description

+

signedUrl

+

String

+

Explanation:

+

The signed URL that carries the authentication information.

+

Default value:

+

None

+

actualSignedRequestHeaders

+

Map<String, String>

+

Explanation:

+

Actual headers in the request initiated using the signed URL. In Map, the String key and value indicate the name and value of the request header respectively.

+

Default value:

+

None

+
+
+
+

Code Example: Creating a Bucket

This example uses HttpMethodEnum.PUT to create bucket examplebucket based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.util.Map;
+public class CreateBucket001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.PUT, expireSeconds);
+            request.setBucketName("examplebucket");
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Creating bucket using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a PUT request to create a bucket.
+            String location = "your bucket location";
+            Request httpRequest =
+                    builder.url(response.getSignedUrl())
+                            .put(
+                                    RequestBody.create(
+                                            null,
+                                            ("<CreateBucketConfiguration><Location>"
+                                                    + location
+                                                    + "</Location></CreateBucketConfiguration>").getBytes()))
+                            .build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("\tStatus:" + res.code());
+            if (res.body() != null) {
+                System.out.println("\tContent:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("CreateBucket successfully");
+        } catch (ObsException e) {
+            System.out.println("CreateBucket failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("CreateBucket failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Uploading an Object

This example uses HttpMethodEnum.PUT to upload object objectname to bucket examplebucket based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.util.HashMap;
+import java.util.Map;
+public class PutObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            Map<String, String> headers = new HashMap<>();
+            String contentType = "text/plain";
+            headers.put("Content-Type", contentType);
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.PUT, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setHeaders(headers);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Creating object using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a PUT request to upload an object.
+            Request httpRequest =
+                    builder.url(response.getSignedUrl())
+                            .put(RequestBody.create(MediaType.parse(contentType), "Hello OBS".getBytes("UTF-8")))
+                            .build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("PutObject successfully");
+        } catch (ObsException e) {
+            System.out.println("PutObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("PutObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Downloading an Object

This example uses HttpMethodEnum.GET to download object objectname from bucket examplebucket based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import java.io.InputStream;
+import java.util.Map;
+public class GetObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Getting object using temporary signature url:");
+            System.out.println("SignedUrl:" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a GET request to download an object.
+            Request httpRequest = builder.url(response.getSignedUrl()).get().build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            InputStream objectContent = null;
+            if (res.body() != null) {
+                objectContent = res.body().byteStream();
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            if(objectContent != null) {
+                // objectContent is the file stream to download.
+                // You can read the objectContent stream to download the file. If the stream is not read for a long time, it will be disconnected from the server.
+            }
+            res.close();
+            System.out.println("getObject successfully");
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing Objects

This example uses HttpMethodEnum.GET to list object in bucket examplebucket based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import java.util.Map;
+public class ListObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, expireSeconds);
+            request.setBucketName("examplebucket");
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Getting object list using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a GET request to obtain the object list.
+            Request httpRequest = builder.url(response.getSignedUrl()).get().build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("ListObject successfully");
+        } catch (ObsException e) {
+            System.out.println("ListObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("ListObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Deleting an Object

This example uses HttpMethodEnum.DELETE to delete object objectname from bucket examplebucket based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import java.util.Map;
+public class DeleteObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.DELETE, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Deleting object using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a DELETE request to delete an object.
+            Request httpRequest = builder.url(response.getSignedUrl()).delete().build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("\tStatus:" + res.code());
+            if (res.body() != null) {
+                System.out.println("\tContent:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("deleteObjects successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Initiating a Multipart Upload

This example uses HttpMethodEnum.POST to initiate a multipart upload based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.SpecialParamEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.util.Map;
+public class InitiateMultiPartUpload001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.POST, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            request.setSpecialParam(SpecialParamEnum.UPLOADS);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("initiate multipart upload using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a POST request to initiate the multipart upload.
+            Request httpRequest = builder.url(response.getSignedUrl()).post(RequestBody.create(null, "")).build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("InitiateMultiPartUpload successfully");
+        } catch (ObsException e) {
+            System.out.println("InitiateMultiPartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("InitiateMultiPartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Uploading a Part

This example uses HttpMethodEnum.PUT to upload a part based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.util.HashMap;
+import java.util.Map;
+public class UploadPart001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.PUT, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            Map<String, Object> queryParams = new HashMap<String, Object>();
+            // Set the partNumber parameter, for example, queryParams.put("partNumber", "1").
+            queryParams.put("partNumber", "partNumber");
+            queryParams.put("uploadId", "your uploadId");
+            request.setQueryParams(queryParams);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("upload part using temporary signature url:");
+            System.out.println("SignedUrl:" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a PUT request to upload a part.
+            Request httpRequest =
+                    builder.url(response.getSignedUrl())
+                            .put(RequestBody.create(null, new byte[6 * 1024 * 1024]))
+                            .build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("UploadPart successfully");
+        } catch (ObsException e) {
+            System.out.println("UploadPart failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("UploadPart failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing Uploaded Parts

This example uses HttpMethodEnum.PUT to list uploaded parts based on a signed URL. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import java.util.HashMap;
+import java.util.Map;
+public class ListUploadedParts001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            Map<String, Object> queryParams = new HashMap<String, Object>();
+            queryParams.put("uploadId", "your uploadId");
+            request.setQueryParams(queryParams);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("list parts using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a GET request to list uploaded parts.
+            Request httpRequest = builder.url(response.getSignedUrl()).get().build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("ListParts successfully");
+        } catch (ObsException e) {
+            System.out.println("ListParts failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("ListParts failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Assembling Parts

This example uses HttpMethodEnum.POST to assemble parts based on a signed URL. The validity period of the URL is 3,600 seconds.

+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import java.util.HashMap;
+import java.util.Map;
+public class CompleteMultiPartUpload001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.POST, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            Map<String, String> headers = new HashMap<>();
+            String contentType = "application/xml";
+            headers.put("Content-Type", contentType);
+            request.setHeaders(headers);
+            Map<String, Object> queryParams = new HashMap<>();
+            queryParams.put("uploadId", "your uploadId");
+            request.setQueryParams(queryParams);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("complete multipart upload using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // The following content is used as an example. You need to replace it with the responses of the request for listing uploaded parts.
+            String content = "<CompleteMultipartUpload>";
+            content += "<Part>";
+            content += "<PartNumber>1</PartNumber>";
+            content += "<ETag>da6a0d097e307ac52ed9b4ad551801fc</ETag>";
+            content += "</Part>";
+            content += "<Part>";
+            content += "<PartNumber>2</PartNumber>";
+            content += "<ETag>da6a0d097e307ac52ed9b4ad551801fc</ETag>";
+            content += "</Part>";
+            content += "</CompleteMultipartUpload>";
+            // Make a POST request to assemble the uploaded parts.
+            Request httpRequest =
+                    builder.url(response.getSignedUrl())
+                            .post(RequestBody.create(MediaType.parse(contentType), content.getBytes("UTF-8")))
+                            .build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("\tStatus:" + res.code());
+            if (res.body() != null) {
+                System.out.println("\tContent:" + res.body().string() + "\n");
+            }
+            res.close();
+        } catch (ObsException e) {
+            System.out.println("CompleteMultiPartUpload failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("CompleteMultiPartUpload failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Downloading an Object Encrypted Using SSE-C

This example uses HttpMethodEnum.GET to download an object encrypted using SSE-C. The validity period of the URL is 3,600 seconds.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.HttpMethodEnum;
+import com.obs.services.model.TemporarySignatureRequest;
+import com.obs.services.model.TemporarySignatureResponse;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import java.util.HashMap;
+import java.util.Map;
+public class GetObject003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Download an object encrypted using SSE-C.
+            // Set the validity period of the URL to 3600 seconds.
+            long expireSeconds = 3600L;
+            TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, expireSeconds);
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectname");
+            // Set the encryption method to SSE-C.
+            Map<String, String> headers = new HashMap<>();
+            headers.put("x-obs-server-side-encryption-customer-algorithm", "AES256");
+            // Set the key used for encryption, which is a Base64-encoded 256-bit value.
+            headers.put(
+                    "x-obs-server-side-encryption-customer-key",
+                    "your base64 sse-c key generated by AES-256 algorithm");
+            // Set the MD5 value of the key used for encryption, which is a Base64-encoded, 128-bit MD5 value.
+            headers.put("x-obs-server-side-encryption-customer-key-MD5", "the md5 value of your sse-c key");
+            request.setHeaders(headers);
+            TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+            System.out.println("Getting object using temporary signature url:");
+            System.out.println("\t" + response.getSignedUrl());
+            Request.Builder builder = new Request.Builder();
+            for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+                builder.header(entry.getKey(), entry.getValue());
+            }
+            // Make a GET request to download an object.
+            Request httpRequest = builder.url(response.getSignedUrl()).get().build();
+            OkHttpClient httpClient =
+                    new OkHttpClient.Builder()
+                            .followRedirects(false)
+                            .retryOnConnectionFailure(false)
+                            .cache(null)
+                            .build();
+            Call c = httpClient.newCall(httpRequest);
+            Response res = c.execute();
+            System.out.println("Status:" + res.code());
+            if (res.body() != null) {
+                System.out.println("Content:" + res.body().string() + "\n");
+            }
+            res.close();
+            System.out.println("getObject successfully");
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
  • HttpMethodEnum is an enumeration function defined in OBS SDK for Java, whose value indicates the request method types.
+ +
+

Integrity Check When Uploading an Object

This example uses content-md5 for integrity check when using a temporary URL to upload an object to OBS.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
import com.obs.services.ObsClient;
+import com.obs.services.internal.utils.ServiceUtils;
+import com.obs.services.model.*;
+import okhttp3.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.Map;
+public class Create_TemporarySignature_Uploadobject {
+   public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
+// Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT"); 
+        // Create an instance of ObsClient.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+        // Set the validity period of the URL to 3600 seconds.
+        long expireSeconds = 3600L;
+        Map<String, String> headers = new HashMap<String, String>();
+        String localFile_path = "localFile_path";
+        //Convert the local file into a stream and calculate its MD5 value.
+        try (FileInputStream fileInputStream = new FileInputStream(localFile_path)) {
+            String md5 = ServiceUtils.toBase64(ServiceUtils.computeMD5Hash(fileInputStream));
+            headers.put("content-md5",md5);
+        }
+        TemporarySignatureRequest request = new  TemporarySignatureRequest(HttpMethodEnum.PUT, expireSeconds);
+        request.setBucketName("your_bucketname");
+        request.setObjectKey("objectkey");
+        request.setHeaders(headers);
+        TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
+        System.out.println("Creating object using temporary signature url:");
+        System.out.println("\t" + response.getSignedUrl());
+        Request.Builder builder = new Request.Builder();
+        for (Map.Entry<String, String> entry : response.getActualSignedRequestHeaders().entrySet()) {
+            builder.header(entry.getKey(), entry.getValue());
+        }
+        // Make a PUT request to upload the file.
+        Request httpRequest = builder.url(response.getSignedUrl())
+                .put(RequestBody.create(getBytesByFile(localFile_path))).build();
+        OkHttpClient httpClient = new OkHttpClient.Builder().followRedirects(false).retryOnConnectionFailure(false)
+                .cache(null).build();
+        Call c = httpClient.newCall(httpRequest);
+        Response res = c.execute();
+        System.out.println("\tStatus:" + res.code());
+        if (res.body() != null) {
+            System.out.println("\tContent:" + res.body().string() + "\n");
+        }
+        res.close();
+    }
+    public static byte[] getBytesByFile(String pathStr) {
+        File file = new File(pathStr);
+        try (FileInputStream fis = new FileInputStream(file);
+             ByteArrayOutputStream bos = new ByteArrayOutputStream(1000)) {
+            byte[] b = new byte[1000];
+            int n;
+            while ((n = fis.read(b)) != -1) {
+                bos.write(b, 0, n);
+            }
+            return bos.toByteArray();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1000.html b/docs/obs_3rd_party/java_sdk/obs_21_1000.html new file mode 100644 index 000000000..c35038547 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1000.html @@ -0,0 +1,31 @@ + + +

Versioning

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1001.html b/docs/obs_3rd_party/java_sdk/obs_21_1001.html new file mode 100644 index 000000000..c7d22318a --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1001.html @@ -0,0 +1,16 @@ + + +

Overview

+

You can use versioning to store multiple versions of an object in a bucket.

+

When versioning is enabled for a bucket, OBS keeps multiple versions of an object in the bucket, allowing you to easily retrieve and restore historical versions or recover data in the event of accidental changes or application failures.

+

By default, versioning is disabled for new OBS buckets. In this case, if a newly uploaded object is using the name of the previously uploaded one, the new object will overwrite the previous one.

+

For details about different versioning operations, see:

+ +

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1002.html b/docs/obs_3rd_party/java_sdk/obs_21_1002.html new file mode 100644 index 000000000..87492d8a0 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1002.html @@ -0,0 +1,249 @@ + + +

Configuring Versioning for a Bucket

+

Function

You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover your data in the event of accidental actions or application failures.

+

This API configures the versioning status for a bucket.

+
+

Restrictions

  • To configure versioning for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketVersioning in IAM or PutBucketVersioning in a bucket policy).
+
+

Method

obsClient.setBucketVersioning(final SetBucketVersioningRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetBucketVersioningRequest

+

Yes

+

Explanation:

+

Request parameters for bucket versioning configuration. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketVersioningRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

status

+

VersioningStatusEnum

+

Yes

+

Explanation:

+

Versioning status of the bucket.

+

Value range:

+

See Table 3.

+
+
+ +
+ + + + + + + + + + + + + +
Table 3 VersioningStatusEnum

Constant

+

Default Value

+

Description

+

SUSPENDED

+

Suspended

+

Versioning is suspended.

+

ENABLED

+

Enabled

+

Versioning is enabled.

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 4 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example enables and suspends versioning of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketVersioningConfiguration;
+import com.obs.services.model.VersioningStatusEnum;
+public class SetBucketVersioning001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Enable versioning.
+            obsClient.setBucketVersioning(
+                    "examplebucket", new BucketVersioningConfiguration(VersioningStatusEnum.ENABLED));
+            // Suspend versioning.
+            obsClient.setBucketVersioning(
+                    "examplebucket", new BucketVersioningConfiguration(VersioningStatusEnum.SUSPENDED));
+            System.out.println("setBucketVersioning successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketVersioning failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketVersioning failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1003.html b/docs/obs_3rd_party/java_sdk/obs_21_1003.html new file mode 100644 index 000000000..099acd529 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1003.html @@ -0,0 +1,239 @@ + + +

Obtaining the Versioning Status of a Bucket

+

Function

You can enable versioning to automatically maintain previous versions of an object. When versioning is enabled, you can access earlier versions of an object to recover your data in the event of accidental actions or application failures.

+

This API obtains the versioning status of a bucket.

+
+

Restrictions

  • To view the versioning status of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketVersioning in IAM or GetBucketVersioning in a bucket policy).
+
+

Method

obsClient.getBucketVersioning(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters for viewing the versioning status of a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 3 BucketVersioningConfiguration

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

status

+

VersioningStatusEnum

+

Explanation:

+

Versioning status of the bucket.

+

Value range:

+

See Table 4.

+
+
+ +
+ + + + + + + + + + + + + +
Table 4 VersioningStatusEnum

Constant

+

Default Value

+

Description

+

SUSPENDED

+

Suspended

+

Versioning is suspended.

+

ENABLED

+

Enabled

+

Versioning is enabled.

+
+
+
+

Code Examples

This example views the versioning status of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketVersioningConfiguration;
+public class GetBucketVersioning001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // View the versioning status of a bucket.
+            BucketVersioningConfiguration status = obsClient.getBucketVersioning("examplebucket");
+            System.out.println("getBucketVersioning successfully");
+            System.out.println("getVersioningStatus:" + status.getVersioningStatus());
+        } catch (ObsException e) {
+            System.out.println("getBucketVersioning failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketVersioning failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1004.html b/docs/obs_3rd_party/java_sdk/obs_21_1004.html new file mode 100644 index 000000000..c323e6efd --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1004.html @@ -0,0 +1,938 @@ + + +

Obtaining an Object Version

+

Function

You can call ObsClient.getObject to obtain an object version by specifying the version ID (versionId).

+
+

Restrictions

  • To download an object, you must be the bucket owner or have the required permission (obs:object:GetObject in IAM or GetObject in a bucket policy).
+
  • Objects in the Cold storage class can be downloaded only when they are restored.
+
+

Method

obsClient.getObject(GetObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectRequest

+

Yes

+

Explanation:

+

Request parameters for downloading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID. If version ID is left blank, the latest version of the object will be downloaded.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

rangeStart

+

Long

+

No

+

Explanation:

+

Start position for object download.

+

Value range:

+

A non-negative integer.

+

Default value:

+

None

+

rangeEnd

+

Long

+

No

+

Explanation:

+

End position for object download.

+

Restrictions:

+

The upper limit of the value is the object length minus 1, in bytes.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

IfModifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

IfUnmodifiedSince

+

Date

+

No

+

Explanation:

+

The object is returned if it has not been modified since the specified time; otherwise, an error is returned.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header. For details, see Table 7.

+

replaceMetadata

+

ObjectRepleaceMetadata

+

No

+

Explanation:

+

Additional information about the object. For details, see Table 3.

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Data transmission listener for obtaining the download progress. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ObjectRepleaceMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

Expires header in the response. It specifies the cache expiration time of the web page when the object is downloaded.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object in a download.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 5 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 6.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 7 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + +
Table 8 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 9 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 10 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 11 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 12 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the file data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 13 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 10.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 12.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+
+

Code Examples

This example sets the version ID to obtain object versions and views the versioning status of object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+public class GetObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the version ID to obtain object versions.
+            ObsObject obsObject = obsClient.getObject("examplebucket", "objectname", "versionid1");
+            System.out.println("getObject successfully");
+            obsObject.getObjectContent().close();
+        } catch (ObsException e) {
+            System.out.println("getObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1005.html b/docs/obs_3rd_party/java_sdk/obs_21_1005.html new file mode 100644 index 000000000..4420791f2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1005.html @@ -0,0 +1,1193 @@ + + +

Copying an Object Version

+

Function

This API copies an object version in a specified bucket.

+

You can call ObsClient.copyObject to copy an object version by specifying the version ID (versionId).

+
+

Restrictions

  • To copy an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
  • You must have the read permission on the source object.
  • The object copy request carries the information about the source bucket and object to be copied in the header field. The message body cannot be carried.
  • Cross-bucket replication in the same region is supported, but cross-region replication is not supported.
  • An object copy can be up to 5 GB in size. If the source object exceeds 5 GB, you can only perform a multipart copy.
  • If the source object is in the Cold storage class, you must restore it first.
+
+

Method

obsClient.copyObject(CopyObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

CopyObjectRequest

+

Yes

+

Explanation:

+

Request parameters for copying an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CopyObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Target bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Target object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 3.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header used for encrypting the target object. For details, see Table 4.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined during the object copy. For details, see Table 8.

+

Default value:

+

None

+

successRedirectLocation

+

String

+

No

+

Explanation:

+

Address (URL) to which a successfully answered request is redirected.

+
  • If the value is valid and the request is successful, OBS returns status code 303. Location contains SuccessActionRedirect as well as the bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this parameter. In such case, the Location header is the object address, and OBS returns a status code based on whether the operation succeeds or fails.
+

Default value:

+

None

+

sourceBucketName

+

String

+

Yes

+

Explanation:

+

Name of the source bucket.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

sourceObjectKey

+

String

+

Yes

+

Explanation:

+

Source object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

newObjectMetadata

+

ObjectMetadata

+

No

+

Explanation:

+

User-defined metadata of the target object. For details, see Table 15.

+

Restrictions:

+

newObjectMetadata must be used together with replaceMetadata.

+

Default value:

+

None

+

replaceMetadata

+

boolean

+

No

+

Explanation:

+

Whether to rewrite the metadata of the source object.

+

Restrictions:

+

replaceMetadata must be used together with newObjectMetadata.

+

Value range:

+

true: The metadata of the source object is rewritten.

+

false: The metadata of the source object is not rewritten.

+

Default value:

+

None

+

ifModifiedSince

+

java.util.Date

+

No

+

Explanation:

+

The source object is copied if it has been modified since the specified time; otherwise, an exception is thrown.

+

Default value:

+

None

+

ifUnmodifiedSince

+

java.util.Date

+

No

+

Explanation:

+

If the source object has not been modified since the specified time, it is copied. Otherwise, an exception is thrown.

+

Default value:

+

None

+

ifMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is the same as the preset ETag, the object is returned. Otherwise, an error is returned. The ETag of the source object is the MD5 value of it.

+

Restrictions:

+
  • If the object copy request includes ifUnmodifiedSince, ifMatchTag, ifModifiedSince, or ifNoneMatchTag, and the specified condition is not met, the copy will fail and an exception will be thrown with HTTP status code 412 precondition failed returned.
  • ifModifiedSince and ifNoneMatchTag can be used together. So do ifUnmodifiedSince and ifMatchTag.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

ifNoneMatchTag

+

String

+

No

+

Explanation:

+

Preset ETag. If the ETag of the object to be downloaded is different from the preset ETag, the object is returned. Otherwise, an error is returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Version ID of the source object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

sseCHeaderSource

+

SseCHeader

+

No

+

Explanation:

+

Server-side decryption header used for decrypting the source object. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 5.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+
In the preceding formats:
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 7.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 6.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 5 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 6 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 7 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 8 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 9.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 10.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 10 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 12.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 11.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 11 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 12 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 13.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 14.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 13 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 14 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 15 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the file data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 16.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 16 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 17 CopyObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

lastModified

+

java.util.Date

+

Explanation:

+

Last time the target object was modified.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of the target object. Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Version ID of the target object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

copySourceVersionId

+

String

+

Explanation:

+

Version ID of the source object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of the target object.

+

Value range:

+

See Table 16.

+

Default value:

+

None

+
+
+
+

Code Examples

This example sets a version ID to copy object versions of sourceobjectname from bucket sourceexamplebucket to another bucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CopyObjectRequest;
+public class CopyObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Copy object versions.
+            CopyObjectRequest request = new CopyObjectRequest();
+            request.setSourceBucketName("sourceexamplebucket");
+            request.setSourceObjectKey("sourceobjectname");
+            // Set the version ID of the object to be copied.
+            request.setVersionId("versionid");
+            request.setDestinationBucketName("destexamplebucket");
+            request.setDestinationObjectKey("destobjectname");
+            obsClient.copyObject(request);
+            System.out.println("copyObject successfully");
+        } catch (ObsException e) {
+            System.out.println("copyObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("copyObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1006.html b/docs/obs_3rd_party/java_sdk/obs_21_1006.html new file mode 100644 index 000000000..973bb6f0b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1006.html @@ -0,0 +1,295 @@ + + +

Restoring a Specific Cold Object Version

+

Function

This API downloads a Cold object. To download such an object, you must restore it first. For the options for the restore speed, see Table 3.

+

You can call ObsClient.restoreObject to restore a Cold object version by specifying the versionId.

+
+

Restrictions

  • To restore a Cold object, you must be the bucket owner or have the required permission (obs:object:RestoreObject in IAM or RestoreObject in a bucket policy.)
  • The object specified in ObsClient.restoreObject must be in the Cold storage class. Otherwise, an exception will be thrown when you call this API.
+
+

Method

obsClient.restoreObject(RestoreObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

RestoreObjectRequest

+

Yes

+

Explanation:

+

Request parameters for restoring a Cold object version. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 RestoreObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Version ID of the Cold object to restore.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is specified.

+

days

+

int

+

Yes

+

Explanation:

+

After an object is restored, a Standard copy is generated for the object. This parameter specifies how long the Standard copy can be retained, that is, the validity period of the restored object.

+

Restrictions:

+

The value must be a positive integer.

+

Value range:

+

The value ranges from 1 to 30, in days.

+

Default value:

+

None

+

tier

+

RestoreTierEnum

+

No

+

Explanation:

+

The restore option, which indicates the time spent on restoring the object.

+

Value range:

+

For details, see Table 3.

+

Default value:

+

Standard

+
+
+ +
+ + + + + + + + + + + + + +
Table 3 RestoreTierEnum

Constant

+

Default Value

+

Description

+

EXPEDITED

+

Expedited

+

Objects can be restored at an expedited speed within 1 to 5 minutes.

+

STANDARD

+

Standard

+

Objects can be restored at a standard speed within 3 to 5 hours.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 4 RestoreObjectStatus

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example restores object version objectname in bucket examplebucket at an expedited speed and retains the restored object for one day.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.RestoreObjectRequest;
+import com.obs.services.model.RestoreTierEnum;
+public class RestoreObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Restore an object version at an expedited speed.
+            RestoreObjectRequest request = new RestoreObjectRequest("examplebucket", "objectname", 1);
+            request.setRestoreTier(RestoreTierEnum.EXPEDITED);
+            request.setVersionId("versionid");
+            obsClient.restoreObject(request);
+            System.out.println("RestoreObject successfully");
+        } catch (ObsException e) {
+            System.out.println("RestoreObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("RestoreObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1007.html b/docs/obs_3rd_party/java_sdk/obs_21_1007.html new file mode 100644 index 000000000..bfe43914d --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1007.html @@ -0,0 +1,1651 @@ + + +

Listing Object Versions

+

Function

This API lists some or all of the object versions in a bucket. When listing the object versions, you can specify the criteria such as the prefix, number, and start position. Returned object versions are listed in alphabetical order by object name.

+

The returned results of ObsClient.listVersions include the object versions and delete markers.

+
+

Restrictions

  • To list object versions in a bucket, you must be the bucket owner or have the required permission (obs:bucket:ListBucketVersions in IAM or ListBucketVersions in a bucket policy).
  • A maximum of 1,000 object versions can be returned in a single request. If a bucket contains more than 1,000 object versions, you can use pagination to list all versions. If ListVersionsResult.isTruncated is true, only part of object versions are returned. In this case, you can use ListVersionsResult.getNextKeyMarker and ListVersionsResult.getNextVersionIdMarker to obtain the start position for the next listing.
+
+

Method

obsClient.listVersions(ListVersionsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

ListVersionsRequest

+

Yes

+

Explanation:

+

Request parameters for listing object versions in a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 ListVersionsRequest parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

String

+

No

+

Explanation:

+

Prefix that the names of objects to list must contain.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

keyMarker

+

String

+

No

+

Explanation:

+

Object name to start with when listing object versions in a bucket. All object versions following this parameter are listed in alphabetical order.

+

Restrictions:

+

This parameter is only available for listing objects with multiple versions.

+

Value range:

+

The value of nextKeyMarker in the response body of the last request.

+

Default value:

+

None

+

maxKeys

+

int

+

No

+

Explanation:

+

The maximum number of object versions returned in the response in alphabetical order.

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is beyond this range, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

String

+

No

+

Explanation:

+

This parameter is used to group object names. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix. If only delimiter is set to d, objects abcd and abcde are grouped into a commonPrefix with abcd as the prefix, and bbcde is grouped separately into another commonPrefix with bbcd as the prefix.

+

For a PFS, if this parameter is not specified, all the contents in the current directory are recursively listed by default, and subdirectories are also listed. In big data scenarios, PFSs usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the contents in the current directory but exclude the contents in subdirectories, thereby accelerating the listing.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionIdMarker

+

String

+

No

+

Explanation:

+

Version ID you want to start listing from. All object versions following the value specified by this parameter are listed in alphabetical order by object name and version ID. This parameter must be used together with keyMarker. keyMarker specifies the object name, and versionIdMarker specifies the version of the specified object.

+

Restrictions:

+
  • This parameter is only available for listing objects with multiple versions.
  • If the object version specified by versionIdMarker and the object name specified by keyMarker do not match, versionIdMarker is invalid.
+

Value range:

+

Object version ID, that is, the value of nextVersionIdMarker in the response body of the last request.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 ListVersionsResult

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

prefix

+

String

+

Explanation:

+

Object name prefix.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you specify logs/ as the prefix, logs/day1, logs/day2, and logs/day3 will be returned. If this parameter is left blank and there are no other filtering criteria, all objects in the bucket will be returned.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionIdMarker

+

String

+

Explanation:

+

Object version for the object specified by KeyMarker. All object versions following the value specified by this parameter are listed in alphabetical order by object name and version ID. This parameter must be used together with KeyMarker. KeyMarker specifies the object name, and versionIdMarker specifies the version of the specified object.

+

Restrictions:

+
  • This parameter is only available for listing objects with multiple versions.
  • If the object version specified by versionIdMarker and the object name specified by keyMarker do not match, versionIdMarker is invalid.
+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

nextVersionIdMarker

+

String

+

Explanation:

+

Version ID to start with in the next request for listing object versions. It must be used together with nextKeyMarker. If only part of the object versions are returned for the current request, this parameter is included in the response for your use in the subsequent request.

+

Restrictions:

+

This parameter is only available for listing objects with multiple versions.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectSummaries

+

List<ObsObject>

+

Explanation:

+

Object information. For details, see Table 4.

+

commonPrefixes

+

List<String>

+

Explanation:

+

List of object name prefixes grouped according to the delimiter parameter (if specified)

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

truncated

+

boolean

+

Explanation:

+

Whether all objects are returned in the response. A maximum of 1,000 objects can be listed at a time. If the number of objects is greater than 1,000, the objects beyond 1,000 cannot be returned.

+

Value range:

+

true: Not all objects are returned.

+

false: All objects are returned.

+

Default value:

+

None

+

keyMarker

+

String

+

Explanation:

+

Object name to start listing from. All object versions following the value specified by this parameter are listed in alphabetical order by object name.

+

Restrictions:

+

This parameter is only available for listing objects with multiple versions.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

maxKeys

+

int

+

Explanation:

+

Maximum number of objects to list. No more than the specified number of objects can be returned in the response in alphabetical order.

+

Value range:

+

The value ranges from 1 to 1000. If the specified value is beyond this range, only 1,000 objects are returned.

+

Default value:

+

1000

+

delimiter

+

String

+

Explanation:

+

Object names are grouped by this parameter, which is often used with Prefix. If a prefix is specified, objects with the same string from the prefix to the first delimiter are grouped into one CommonPrefixes. If no prefix is specified, objects with the same string from the first character to the first delimiter are grouped into one CommonPrefixes.

+

Assume that a bucket has objects abcd, abcde, and bbcde in it. If delimiter is set to d and prefix is set to a, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix. If only delimiter is set to d, files abcd and abcde are grouped into a CommonPrefixes with abcd as the prefix, and bbcde is grouped separately into another CommonPrefixes with bbcd as the prefix.

+

For a PFS, if this parameter is not specified, all the contents in the current directory are recursively listed by default, and subdirectories are also listed. In big data scenarios, PFSs usually have multiple directory levels and each directory level has a large number of files. In such case, you are advised to configure [delimiter=/] to list the contents in the current directory but exclude the contents in subdirectories, thereby accelerating the listing.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

nextKeyMarker

+

String

+

Explanation:

+

Object name to start with for the next request for listing object versions. If only part of the object versions are returned for the current request, this parameter is included in the response for your use in the subsequent request.

+

Restrictions:

+

This parameter is only available for listing objects with multiple versions.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

location

+

String

+

Explanation:

+

Region where a bucket is located.

+

Value range:

+

To learn about valid regions and endpoints, see Regions and Endpoints. An endpoint is the request address for calling an API. Endpoints vary depending on services and regions. To obtain the regions and endpoints, contact the enterprise administrator.

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

versions

+

VersionOrDeleteMarker[]

+

Explanation:

+

Object version information. For details, see Table 8.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 ObsObject

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

Owner of the object. For details, see Table 5.

+

metadata

+

ObjectMetadata

+

Explanation:

+

Object metadata. For details, see Table 6.

+

objectContent

+

InputStream

+

Explanation:

+

Object data stream.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 6 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the file data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 7 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 VersionOrDeleteMarker

Parameter

+

Type

+

Description

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

key

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

isLatest

+

boolean

+

Explanation:

+

Whether the object is the latest version.

+

Value range:

+
  • true: The object is the latest version.
  • false: The object is not the latest version.
+

Default value:

+

false

+

lastModified

+

Date

+

Explanation:

+

Time when the object was last modified.

+

Value range:

+

UTC time

+

Default value:

+

None

+

owner

+

Owner

+

Explanation:

+

User information, including the domain ID and name of the object owner. For details, see Table 5.

+

etag

+

String

+

Explanation:

+

Base64-encoded, 128-bit MD5 value of an object. ETag is the unique identifier of the object contents and is used to determine whether the contents of an object are changed. For example, if the ETag value is A when an object is uploaded and is B when the object is downloaded, this indicates the contents of the object are changed. The ETag reflects changes only to the contents of an object, not its metadata. Objects created by the upload and copy operations have unique ETags after being encrypted using MD5.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

size

+

long

+

Explanation:

+

Object size, in bytes.

+

Value range:

+

The value ranges from 0 TB to 48.8 TB, in bytes.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+

isDeleteMarker

+

boolean

+

Explanation:

+

Whether the object version is a delete marker.

+

Value range:

+

true

+

false

+

Default value:

+

None

+
+
+
+

Code Example: Listing Object Versions in a Bucket

This example lists object versions in bucket examplebucket. A maximum of 1,000 object versions can be returned.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Listing object versions.
+            ListVersionsResult result = obsClient.listVersions("examplebucket");
+            System.out.println("listVersions successfully");
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Version Count to List

This example lists a specified number of object versions in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List a specified number of object versions.
+            ListVersionsResult result = obsClient.listVersions("examplebucket", 100);
+            System.out.println("listVersions successfully");
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Version Prefix to List

This example specifies a prefix to list object versions in bucket examplebucket. A maximum of 100 object versions will be returned.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions003 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List object versions by specifying a prefix.
+            // List 100 object versions with the specified prefix.
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 100);
+            request.setPrefix("prefix");
+            ListVersionsResult result = obsClient.listVersions(request);
+            System.out.println("listVersions successfully");
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Specifying the Start Position to List

This example lists 100 object versions whose names follow test in lexicographical order in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List objects from a specified start position.
+            // List 100 object versions whose names following test in lexicographic order.
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 100);
+            request.setKeyMarker("test");
+            ListVersionsResult result = obsClient.listVersions(request);
+            System.out.println("listVersions successfully");
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Using Pagination to List All Versions

This example lists 100 object versions whose names follow test in lexicographical order in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions005 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List all object versions using pagination.
+            ListVersionsResult result;
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 100);
+            do {
+                result = obsClient.listVersions(request);
+                System.out.println("listVersions successfully");
+                for (VersionOrDeleteMarker v : result.getVersions()) {
+                    System.out.println("Key:" + v.getKey());
+                    System.out.println("Owner:" + v.getOwner());
+                    System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+                }
+                request.setKeyMarker(result.getNextKeyMarker());
+                request.setVersionIdMarker(result.getNextVersionIdMarker());
+            } while (result.isTruncated());
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing All Object Versions in a Folder

There is no concept of folders in OBS. All elements stored in OBS buckets are objects. Folders are actually objects whose sizes are 0 and whose names end with a slash (/). You can set a folder name as a prefix to list objects in this folder. This example lists all object versions in a folder.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions006 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            //List all object versions in a folder.
+            ListVersionsResult result;
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 100);
+            // Set folder name dir/ as the prefix.
+            request.setPrefix("dir/");
+            do {
+                result = obsClient.listVersions(request);
+                System.out.println("listVersions successfully");
+                for (VersionOrDeleteMarker v : result.getVersions()) {
+                    System.out.println("Key:" + v.getKey());
+                    System.out.println("Owner:" + v.getOwner());
+                    System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+                }
+                request.setKeyMarker(result.getNextKeyMarker());
+                request.setVersionIdMarker(result.getNextVersionIdMarker());
+            } while (result.isTruncated());
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Listing All Object Versions in a Bucket by Folder Name

This example lists all object versions in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ListVersionsRequest;
+import com.obs.services.model.ListVersionsResult;
+import com.obs.services.model.VersionOrDeleteMarker;
+public class ListVersions007 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // List all object versions in the root directory.
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 1000);
+            request.setDelimiter("/");
+            ListVersionsResult result = obsClient.listVersions(request);
+            System.out.println("listVersions successfully");
+            System.out.println("Objects in the root directory:");
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+            listVersionsByPrefix(obsClient, result);
+        } catch (ObsException e) {
+            System.out.println("listVersions failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("listVersions failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+
+
+
+

Code Example: Recursively Listing Object Versions in a Sub-folder

This example recursively lists object versions in a sub-folder.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
    // Recursively list object versions in a sub-folder.
+    static void listVersionsByPrefix(ObsClient obsClient, ListVersionsResult result) throws ObsException {
+        for (String prefix : result.getCommonPrefixes()) {
+            System.out.println("Objects in folder [" + prefix + "]:");
+            ListVersionsRequest request = new ListVersionsRequest("examplebucket", 1000);
+            request.setDelimiter("/");
+            request.setPrefix(prefix);
+            result = obsClient.listVersions(request);
+            for (VersionOrDeleteMarker v : result.getVersions()) {
+                System.out.println("Key:" + v.getKey());
+                System.out.println("Owner:" + v.getOwner());
+                System.out.println("isDeleteMarker:" + v.isDeleteMarker());
+            }
+            listVersionsByPrefix(obsClient, result);
+        }
+    }
+}
+
+
+
  • The code examples above do not involve scenarios where there are more than 1,000 object versions in a folder.
  • Since all folder names end with a slash (/) and the objects and sub-folders to list are under the folder, delimiter is always a slash (/).
  • In the returned result of each recursion, ListVersionsResult.getVersions includes the object versions under the folder, and ListVersionsResult.getCommonPrefixes includes the sub-folders under the folder.
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1008.html b/docs/obs_3rd_party/java_sdk/obs_21_1008.html new file mode 100644 index 000000000..b7304bf71 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1008.html @@ -0,0 +1,626 @@ + + +

Setting an ACL for an Object Version

+

Function

OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can set access control policies for objects. For example, if an object is configured with the public access policy, all users are allowed to read the object. If an object is encrypted with SSE-KMS, the ACL configured for it is not in effect in the cross-tenant case.

+

You can set an ACL when uploading an object or call an ACL API to modify or obtain the ACL of an existing object.

+
+

Restrictions

  • To set an object ACL, you must be the bucket owner or have the required permission (obs:object:PutObjectAcl in IAM or PutObjectAcl in a bucket policy).
+
  • An object ACL supports a maximum of 100 grants.
+
+

Method

obsClient.setObjectAcl(SetObjectAclRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetObjectAclRequest

+

Yes

+

Explanation:

+

Request parameters for setting an object ACL. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 SetObjectAclRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL specified for the object. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 10 for the available options.
  • To use a user-defined ACL, see Table 3 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 6.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 7.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 8 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 10 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 11 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example sets an ACL for the versioned object objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.GroupGrantee;
+import com.obs.services.model.Owner;
+import com.obs.services.model.Permission;
+public class SetObjectAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Define the ACL of the versioned object to Private.
+            obsClient.setObjectAcl("examplebucket", "objectname", AccessControlList.REST_CANNED_PRIVATE, "versionid");
+            AccessControlList acl = new AccessControlList();
+            Owner owner = new Owner();
+            owner.setId("ownerid");
+            acl.setOwner(owner);
+            // Grant the read permission to all users.
+            acl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
+            // Set the ACL for the versioned object.
+            obsClient.setObjectAcl("examplebucket", "objectname", acl, "versionid");
+            System.out.println("setObjectAcl successfully");
+        } catch (ObsException e) {
+            System.out.println("setObjectAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setObjectAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

The owner or grantee ID needed in the ACL indicates the account ID, which can be viewed on the My Credential page of OBS Console.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1009.html b/docs/obs_3rd_party/java_sdk/obs_21_1009.html new file mode 100644 index 000000000..18f4b6d6e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1009.html @@ -0,0 +1,263 @@ + + +

Deleting an Object Version

+

Function

This API deletes an object from a specific bucket.

+

You can call ObsClient.deleteObject to pass a version ID (versionId) to delete an object version.

+
+

Restrictions

  • To delete an object, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or DeleteObject in a bucket policy).
  • If versioning is not enabled for a bucket, deleted objects cannot be recovered.
+
+

Method

obsClient.deleteObject(DeleteObjectRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

DeleteObjectRequest

+

Yes

+

Explanation:

+

Request parameters for deleting an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 DeleteObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 DeleteObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

deleteMarker

+

boolean

+

Explanation:

+

Whether the deleted object is a delete marker.

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+
+

Code Examples

This example passes a version ID (versionId) to delete an object version using ObsClient.deleteObject.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete the object version.
+            obsClient.deleteObject("examplebucket", "objectname", "versionid");
+            System.out.println("deleteObject successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1010.html b/docs/obs_3rd_party/java_sdk/obs_21_1010.html new file mode 100644 index 000000000..130824714 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1010.html @@ -0,0 +1,505 @@ + + +

Obtaining the ACL of an Object Version

+

Function

OBS allows the control of access permissions for objects. By default, only object creators have the read and write permissions on the object. You can call an ACL API to modify or obtain the ACL of an existing object.

+

This API returns the ACL for a specific object version in a bucket.

+
+

Restrictions

  • To obtain an object ACL, you must be the bucket owner or have the required permission (obs:object:GetObjectAcl in IAM or GetObjectAcl in a bucket policy).
+
  • To call this API, you must have the read permission on the ACL of the object.
+
+

Method

obsClient.getObjectAcl(GetObjectAclRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

GetObjectAclRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining the ACL of the object. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 GetObjectAclRequest parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

Yes

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 4.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 6.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 9.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 7.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 8 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 9 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Code Examples

This example returns the ACL information of object version objectname in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+public class GetObjectAcl001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the ACL of the versioned object.
+            AccessControlList acl = obsClient.getObjectAcl("examplebucket", "objectname", "versionid");
+            System.out.println("getObjectAcl successfully");
+            System.out.println(acl);
+        } catch (ObsException e) {
+            System.out.println("getObjectAcl failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectAcl failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1011.html b/docs/obs_3rd_party/java_sdk/obs_21_1011.html new file mode 100644 index 000000000..0a63a02a4 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1011.html @@ -0,0 +1,432 @@ + + +

Batch Deleting Object Versions

+

Function

This API deletes objects in batches from a specific bucket. Deleted objects cannot be recovered.

+

In a batch delete operation, OBS concurrently deletes the specified objects and returns the deletion result of each object.

+

You can call ObsClient.deleteObjects to pass version IDs (versionId) to delete object versions.

+
+

Restrictions

  • To delete objects in a batch, you must be the bucket owner or have the required permission (obs:object:DeleteObject in IAM or DeleteObject in a bucket policy).
  • If versioning is not enabled for a bucket, deleted objects cannot be recovered.
  • A maximum of 1,000 objects can be deleted at a time. If you send a request for deleting more than 1,000 objects, OBS returns an error message.
  • After concurrent tasks are assigned, if an internal error occurs during cyclic deletion of multiple objects, an object may be deleted in the index data but still exist in the metadata.
+
+

Method

obsClient.deleteObjects(DeleteObjectsRequest deleteRequest)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

deleteRequest

+

DeleteObjectsRequest

+

Yes

+

Explanation:

+

Request parameters for deleting objects in batches. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 2 DeleteObjectsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

keyAndVersions

+

List<KeyAndVersion>

+

Yes

+

Explanation:

+

List of objects to be deleted. For details, see Table 3.

+

quiet

+

boolean

+

No

+

Explanation:

+

Response mode to the request for deleting objects in a batch.

+

Value range:

+
  • false: The detailed mode. Results of both successful and failed deletions are returned.
  • true: The quiet mode. Only results of failed deletions are returned.
+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 3 KeyAndVersion

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None. If this parameter is left blank, the latest version of the object is deleted.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 DeleteObjectsResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

deletedObjectResults

+

List<DeleteObjectResult>

+

Explanation:

+

Response results of the request for deleting objects in a batch. For details, see Table 5.

+

errorResults

+

List<ErrorResult>

+

Explanation:

+

List of objects that fail to be deleted. For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 DeleteObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

deleteMarker

+

boolean

+

Explanation:

+

Whether the deleted object is a delete marker.

+

Value range:

+
  • true: The deleted object is a delete marker.
  • false: The deleted object is not a delete marker.
+

Default value:

+

false

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 6 ErrorResult

Parameter

+

Type

+

Description

+

versionId

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

errorCode

+

String

+

Explanation:

+

Error code for the failed deletion.

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

message

+

String

+

Explanation:

+

Error message for the failed deletion.

+
+
+
+

Code Examples

This example passes multiple version IDs (versionId) to batch delete object versions using ObsClient.deleteObjects.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.DeleteObjectsRequest;
+import com.obs.services.model.DeleteObjectsResult;
+import com.obs.services.model.KeyAndVersion;
+import java.util.ArrayList;
+import java.util.List;
+public class DeleteObjects001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete object versions in a batch.
+            DeleteObjectsRequest request = new DeleteObjectsRequest("examplebucket");
+            request.setQuiet(false);
+            List<KeyAndVersion> toDelete = new ArrayList<KeyAndVersion>();
+            toDelete.add(new KeyAndVersion("objectname1", "versionid1"));
+            toDelete.add(new KeyAndVersion("objectname2", "versionid2"));
+            toDelete.add(new KeyAndVersion("objectname3", "versionid3"));
+            request.setKeyAndVersions(toDelete.toArray(new KeyAndVersion[toDelete.size()]));
+            DeleteObjectsResult result = obsClient.deleteObjects(request);
+            System.out.println("deleteObjects successfully");
+            System.out.println("getDeletedObjectResults:" + result.getDeletedObjectResults());
+            System.out.println("getErrorResults:" + result.getErrorResults());
+        } catch (ObsException e) {
+            System.out.println("deleteObjects failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteObjects failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1100.html b/docs/obs_3rd_party/java_sdk/obs_21_1100.html new file mode 100644 index 000000000..d26f53e65 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1100.html @@ -0,0 +1,17 @@ + + +

Lifecycle Management

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1101.html b/docs/obs_3rd_party/java_sdk/obs_21_1101.html new file mode 100644 index 000000000..04f51c71e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1101.html @@ -0,0 +1,17 @@ + + +

Overview

+

OBS allows you to set lifecycle rules for buckets to automatically transition the storage class of an object or delete expired objects, to effectively use storage features and optimize the storage space. You can set multiple lifecycle rules based on the prefix. A lifecycle rule must contain:

+
  • Rule ID, which uniquely identifies the rule
  • Prefix of objects that are under the control of this rule
  • Transition policy of an object of the latest version, which can be specified in either mode:
    1. How many days after the object is created
    2. Transition date
    +
  • Expiration time of an object of the latest version, which can be specified in either mode:
    1. How many days after the object is created
    2. Expiration date
    +
  • Transition policy of a noncurrent object version, which can be specified in the following mode:
    • How many days after an object version becomes a noncurrent one
    +
  • Expiration time of a noncurrent object version, which can be specified in the following mode:
    • How many days after the object becomes a noncurrent object version
    +
  • Identifier specifying whether the setting is effective
+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1102.html b/docs/obs_3rd_party/java_sdk/obs_21_1102.html new file mode 100644 index 000000000..e88fb4e39 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1102.html @@ -0,0 +1,757 @@ + + +

Setting Lifecycle Rules

+

Function

This API configures lifecycle rules for a bucket to periodically delete objects in the bucket or transition objects between storage classes.

+
  1. An object will be automatically deleted by the OBS server once it expires.
  2. The time set in the transition policy of an object must be earlier than its expiration time, and the time set in the transition policy of a noncurrent object version must be earlier than its expiration time.
  3. The configured expiration time and transition policy for a noncurrent object version can only take effect when versioning is enabled or suspended for the bucket where that object version is stored.
+
  • Objects in the Warm storage class have a minimum storage period of 30 days and those in the Cold storage class have a minimum storage period of 90 days. After an object is transitioned to the Cold storage class, if it stays in this storage class for less than 90 days, you still need to pay for a full 90 days.
+
+
+

Restrictions

  • There is no limit on the number of lifecycle rules in a bucket, but the total size of XML descriptions about all lifecycle rules in a bucket cannot exceed 20 KB.
  • A maximum of 20 lifecycle rules can be configured for a parallel file system.
  • To configure a lifecycle rule for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutLifecycleConfiguration in IAM or PutLifecycleConfiguration in a bucket policy).
  • Expired objects will be permanently deleted and cannot be recovered.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
+
+

Method

obsClient.setBucketLifecycle(final SetBucketLifecycleRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

deleteRequest

+

SetBucketLifecycleRequest

+

Yes

+

Explanation:

+

Request parameters for setting the lifecycle rule. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketLifecycleRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

lifecycleConfig

+

LifecycleConfiguration

+

Yes

+

Explanation:

+

Lifecycle rules for the bucket. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + +
Table 3 LifecycleConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

rules

+

List<Rule>

+

No

+

Explanation:

+

List of lifecycle rules. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 Rule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

No

+

Explanation:

+

Lifecycle rule ID.

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

prefix

+

String

+

Yes

+

Explanation:

+

Object name prefix. It identifies the objects the rule applies to. You can leave this parameter blank to apply the rule to all objects in the bucket.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you set prefix to ExampleObject.jpg, the rule applies to object ExampleObject.jpg only. If you set prefix to logs/, the rule applies to the three objects with name starting with logs/. If you leave prefix blank, the rule applies to all objects in the bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

enabled

+

boolean

+

Yes

+

Explanation:

+

Whether to enable the rule.

+

Value range:

+

true: The rule is enabled.

+

false: The rule is disabled.

+

Default value:

+

None

+

expiration

+

Expiration

+

No

+

Explanation:

+

Expiration time of an object. For details, see Table 5.

+

Default value:

+

None

+

noncurrentVersionExpiration

+

NoncurrentVersionExpiration

+

No

+

Explanation:

+

Expiration time of noncurrent object versions. For details, see Table 6.

+

Restrictions:

+
  • This parameter is only available for noncurrent object versions.
  • Versioning must be enabled (or suspended after being enabled) for the bucket.
+

Default value:

+

None

+

transitions

+

List<Transition>

+

No

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 7.

+

Restrictions:

+

This parameter is only available for the current object version.

+

Default value:

+

None

+

noncurrentVersionTransitions

+

List<NoncurrentVersionTransition>

+

No

+

Explanation:

+

Policies for storage class transition of noncurrent versions, including transition time and the storage class after transition. For details, see Table 9.

+

Restrictions:

+
  • This parameter is only available for noncurrent object versions.
  • Versioning must be enabled (or suspended after being enabled) for the bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Expiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

Yes if date is absent during object storage class transition

+

Yes if date or expiredObjectDeleteMarker is absent during object deletion

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect (the object will be deleted).

+

Restrictions:

+

This parameter is only available for the current object version.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

date

+

Date

+

Yes if days is absent during object storage class transition.

+

Yes if days or expiredObjectDeleteMarker is absent during object deletion

+

Explanation:

+

The value must conform to the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are transitioned to the specified storage class or deleted.

+

Default value:

+

None

+

expiredObjectDeleteMarker

+

Boolean

+

Yes if days or date is absent

+

Explanation:

+

Whether to delete expired delete markers. The value can be true or false. If tags are configured in a lifecycle rule, this element cannot be configured.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 6 NoncurrentVersionExpiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

Yes

+

Explanation:

+

Number of days an object is noncurrent before it expires.

+

Restrictions:

+

This parameter is only available for noncurrent object versions.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 Transition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

This parameter is mandatory if date is not configured.

+

Explanation:

+

Number of days after its creation when the object is transitioned.

+

Restrictions:

+

This parameter is only available for the current object version.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

date

+

Date

+

This parameter is mandatory if days is not configured.

+

Explanation:

+

Date when the object will be transitioned.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Yes

+

Explanation:

+

Storage class the object is transitioned to.

+

Restrictions:

+
Restrictions on storage class transitions:
  • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
  • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must first restore these objects and then manually transition their storage classes.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
+
+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 8 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 NoncurrentVersionTransition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

This parameter is mandatory if date is not configured.

+

Explanation:

+

Number of days after its creation when the object is transitioned.

+

Restrictions:

+

This parameter is only available for noncurrent object versions.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Yes

+

Explanation:

+

Storage class the object is transitioned to.

+

Restrictions:

+
Restrictions on storage class transitions:
  • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
  • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must first restore these objects and then manually transition their storage classes.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
+
+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+

Transitions, Expiration, NoncurrentVersionTransitions, AbortIncompleteMultipartUpload, and NoncurrentVersionExpiration must not be all left blank.

+
+

Responses

+
+ + + + + + + + + + + + + +
Table 10 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Setting an Object Transition Policy

This example configures a transition policy for latest and historical object versions in bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.LifecycleConfiguration;
+import com.obs.services.model.StorageClassEnum;
+public class SetBucketLifecycle001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            //Set an object transition policy.
+            LifecycleConfiguration config = new LifecycleConfiguration();
+            LifecycleConfiguration.Rule rule = config.new Rule();
+            rule.setEnabled(true);
+            rule.setId("rule1");
+            rule.setPrefix("prefix");
+            LifecycleConfiguration.Transition transition = config.new Transition();
+            // Specify that objects whose names contain the specified prefix will be transitioned 30 days after creation.
+            transition.setDays(30);
+            // Specify the storage class that the object will be transitioned to.
+            transition.setObjectStorageClass(StorageClassEnum.WARM);
+            // Specify when the objects whose names contain the specified prefix will be transitioned.
+            // transition.setDate(new SimpleDateFormat("yyyy-MM-dd").parse("2018-10-31"));
+            rule.getTransitions().add(transition);
+            LifecycleConfiguration.NoncurrentVersionTransition noncurrentVersionTransition =
+                    config.new NoncurrentVersionTransition();
+            // Specify that objects whose names contain the specified prefix will be transitioned 30 days after being historical versions.
+            noncurrentVersionTransition.setDays(30);
+            // Specify the storage class of the historical object version after transition.
+            noncurrentVersionTransition.setObjectStorageClass(StorageClassEnum.COLD);
+            rule.getNoncurrentVersionTransitions().add(noncurrentVersionTransition);
+            // Set the expiration time of fragments.
+            LifecycleConfiguration.AbortIncompleteMultipartUpload abortIncompleteMultipartUpload = config.new AbortIncompleteMultipartUpload();
+            abortIncompleteMultipartUpload.setDaysAfterInitiation(7);
+            rule.setAbortIncompleteMultipartUpload(abortIncompleteMultipartUpload);
+            config.addRule(rule);
+            obsClient.setBucketLifecycle("examplebucket", config);
+            System.out.println("setBucketLifecycle successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketLifecycle failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketLifecycle failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Setting the Object Expiration Time

This example configures the expiration time of latest and historical object versions in bucket examplebucket.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.LifecycleConfiguration;
+public class SetBucketLifecycle002 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Set the object expiration time.
+            LifecycleConfiguration config = new LifecycleConfiguration();
+            LifecycleConfiguration.Rule rule = config.new Rule();
+            rule.setEnabled(true);
+            rule.setId("rule1");
+            rule.setPrefix("prefix");
+            LifecycleConfiguration.Expiration expiration = config.new Expiration();
+            // Specify that objects whose names contain the specified prefix will expire 60 days after creation.
+            expiration.setDays(60);
+            // Specify when the objects whose names contain the specified prefix will expire.
+            // expiration.setDate(new SimpleDateFormat("yyyy-MM-dd").parse("2018-12-31"));
+            rule.setExpiration(expiration);
+            LifecycleConfiguration.NoncurrentVersionExpiration noncurrentVersionExpiration =
+                    config.new NoncurrentVersionExpiration();
+            // Specify that objects whose names contain the specified prefix will expire after changing into historical versions for 60 days.
+            noncurrentVersionExpiration.setDays(60);
+            rule.setNoncurrentVersionExpiration(noncurrentVersionExpiration);
+            config.addRule(rule);
+            obsClient.setBucketLifecycle("examplebucket", config);
+            System.out.println("setBucketLifecycle successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketLifecycle failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketLifecycle failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1103.html b/docs/obs_3rd_party/java_sdk/obs_21_1103.html new file mode 100644 index 000000000..02cb194d1 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1103.html @@ -0,0 +1,582 @@ + + +

Obtaining Lifecycle Rules

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.

+

This API returns the lifecycle rules of a bucket.

+
+

Restrictions

  • To obtain the lifecycle configuration of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetLifecycleConfiguration in IAM or GetLifecycleConfiguration in a bucket policy).
+
+

Method

obsClient.getBucketLifecycle(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 3 LifecycleConfiguration

Parameter

+

Type

+

Description

+

rules

+

List<Rule>

+

Explanation:

+

List of lifecycle rules. For details, see Table 4.

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 Rule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

No

+

Explanation:

+

Lifecycle rule ID.

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

prefix

+

String

+

Yes

+

Explanation:

+

Object name prefix. It identifies the objects the rule applies to. You can leave this parameter blank to apply the rule to all objects in the bucket.

+

Assume that you have the following objects: logs/day1, logs/day2, logs/day3, and ExampleObject.jpg. If you set prefix to ExampleObject.jpg, the rule applies to object ExampleObject.jpg only. If you set prefix to logs/, the rule applies to the three objects with name starting with logs/. If you leave prefix blank, the rule applies to all objects in the bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

enabled

+

boolean

+

Yes

+

Explanation:

+

Whether the rule is enabled.

+

Value range:

+

true: The rule is enabled.

+

false: The rule is disabled.

+

Default value:

+

None

+

expiration

+

Expiration

+

No

+

Explanation:

+

Expiration time of an object. For details, see Table 5.

+

Default value:

+

None

+

noncurrentVersionExpiration

+

NoncurrentVersionExpiration

+

No

+

Explanation:

+

Expiration time of noncurrent object versions. For details, see Table 6.

+

Restrictions:

+
  • This parameter is only available for noncurrent object versions.
  • Versioning must be enabled (or suspended after being enabled) for the bucket.
+

Default value:

+

None

+

transitions

+

List<Transition>

+

No

+

Explanation:

+

Policies for storage class transition, including transition time and the storage class after transition. For details, see Table 7.

+

Restrictions:

+

This parameter is only available for the current object version.

+

Default value:

+

None

+

noncurrentVersionTransitions

+

List<NoncurrentVersionTransition>

+

No

+

Explanation:

+

Policies for storage class transition of noncurrent versions, including transition time and the storage class after transition. For details, see Table 9.

+

Restrictions:

+
  • This parameter is only available for noncurrent object versions.
  • Versioning must be enabled (or suspended after being enabled) for the bucket.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 5 Expiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

Yes if date is absent during object storage class transition

+

Yes if date or expiredObjectDeleteMarker is absent during object deletion

+

Explanation:

+

Number of days (since the last update was made to the object) after which the lifecycle rule takes effect (the object will be deleted).

+

Restrictions:

+

This parameter is only available for the current object version.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

date

+

Date

+

Yes if days is absent during object storage class transition.

+

Yes if days or expiredObjectDeleteMarker is absent during object deletion

+

Explanation:

+

The value must conform to the ISO8601 standards and indicate UTC 00:00. For example, 2018-01-01T00:00:00.000Z indicates only objects that were last modified before the specified time are transitioned to the specified storage class or deleted.

+

Default value:

+

None

+

expiredObjectDeleteMarker

+

Boolean

+

Yes if days or date is absent

+

Explanation:

+

Whether to delete expired delete markers. The value can be true or false. If tags are configured in a lifecycle rule, this element cannot be configured.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 6 NoncurrentVersionExpiration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

Yes

+

Explanation:

+

Number of days an object is noncurrent before it expires.

+

Restrictions:

+

This parameter is only available for noncurrent object versions.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 Transition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

This parameter is mandatory if date is not configured.

+

Explanation:

+

Number of days after its creation when the object is transitioned.

+

Restrictions:

+

This parameter is only available for the current object version.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

date

+

Date

+

This parameter is mandatory if days is not configured.

+

Explanation:

+

Date when the object will be transitioned.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Yes

+

Explanation:

+

Storage class the object is transitioned to.

+

Restrictions:

+
Restrictions on storage class transitions:
  • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
  • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must first restore these objects and then manually transition their storage classes.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
+
+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 8 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 9 NoncurrentVersionTransition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

days

+

Integer

+

This parameter is mandatory if date is not configured.

+

Explanation:

+

Number of days after its creation when the object is transitioned.

+

Restrictions:

+

This parameter is only available for noncurrent object versions.

+

Value range:

+

A positive integer, in days.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Yes

+

Explanation:

+

Storage class the object is transitioned to.

+

Restrictions:

+
Restrictions on storage class transitions:
  • Only transitions from the Standard storage class to the Warm storage class are supported. To transition objects from Warm to Standard, you must manually do it.
  • Only transitions from the Standard or Warm storage class to the Cold storage class are supported. To transition objects from Cold to Standard or Warm, you must first restore these objects and then manually transition their storage classes.
  • Multi-AZ redundancy is not available for Cold storage. For this reason, buckets or objects with multi-AZ redundancy cannot be transitioned to the Cold storage class based on a lifecycle rule.
+
+

Value range:

+

See Table 8.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the lifecycle configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.LifecycleConfiguration;
+public class GetBucketLifecycle001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // View the lifecycle rules
+            LifecycleConfiguration config = obsClient.getBucketLifecycle("examplebucket");
+            System.out.println("getBucketLifecycle successfully");
+            for (LifecycleConfiguration.Rule rule : config.getRules()) {
+                System.out.println(rule.getId());
+                System.out.println(rule.getPrefix());
+                for (LifecycleConfiguration.Transition transition : rule.getTransitions()) {
+                    System.out.println(transition.getDays());
+                    System.out.println(transition.getStorageClass());
+                }
+                System.out.println(rule.getExpiration() != null ? rule.getExpiration().getDays() : "");
+                for (LifecycleConfiguration.NoncurrentVersionTransition noncurrentVersionTransition :
+                        rule.getNoncurrentVersionTransitions()) {
+                    System.out.println(noncurrentVersionTransition.getDays());
+                    System.out.println(noncurrentVersionTransition.getStorageClass());
+                }
+                System.out.println(
+                        rule.getNoncurrentVersionExpiration() != null
+                                ? rule.getNoncurrentVersionExpiration().getDays()
+                                : "");
+            }
+        } catch (ObsException e) {
+            System.out.println("getBucketLifecycle failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketLifecycle failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1104.html b/docs/obs_3rd_party/java_sdk/obs_21_1104.html new file mode 100644 index 000000000..86acc88f4 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1104.html @@ -0,0 +1,199 @@ + + +

Deleting Lifecycle Rules

+

Function

You can configure lifecycle rules to periodically delete objects or transition objects between storage classes.

+

This API deletes the lifecycle configuration of a bucket.

+
+

Restrictions

  • To delete the lifecycle configuration of a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutLifecycleConfiguration in IAM or PutLifecycleConfiguration in a bucket policy).
  • You cannot use this API to delete a specified lifecycle rule. When you call this API, all lifecycle rules in the bucket are deleted.
+
+

Method

obsClient.deleteBucketLifecycle(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the lifecycle configurations of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteBucketLifecycle001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete the lifecycle configurations.
+            obsClient.deleteBucketLifecycle("examplebucket");
+            System.out.println("deleteBucketLifecycle successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteBucketLifecycle failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteBucketLifecycle failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1400.html b/docs/obs_3rd_party/java_sdk/obs_21_1400.html new file mode 100644 index 000000000..54e64df32 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1400.html @@ -0,0 +1,17 @@ + + +

Cross-Origin Resource Sharing

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1401.html b/docs/obs_3rd_party/java_sdk/obs_21_1401.html new file mode 100644 index 000000000..738c7ae24 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1401.html @@ -0,0 +1,18 @@ + + +

Overview

+

Cross-origin access refers to access between different domains. Restricting cross-origin access is a browser policy for security purposes, that is, the same-origin policy.

+

Due to this same-origin policy, JavaScript in origin A cannot operate objects in origin B or C.

+

The same-origin policy requires the protocols, domain names (or IP addresses), and ports are all the same. If the protocols, domain names, and ports (if specified) of the two web pages are the same, the two web pages are in the same origin.

+

Cross-origin resource sharing (CORS) allows web application programs in one origin to access resources in another.

+

OBS supports CORS rules that allow the resources in OBS to be requested by other domains.

+

+

For more information about the application scenarios of CORS, see:

+ +
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1402.html b/docs/obs_3rd_party/java_sdk/obs_21_1402.html new file mode 100644 index 000000000..1937f60ea --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1402.html @@ -0,0 +1,399 @@ + + +

Configuring a CORS Rule

+

Function

Cross-origin resource sharing (CORS) is a mechanism defined by the World Wide Web Consortium (W3C) that allows a web application program in one domain to access resources located in another one. For general web page requests, website scripts and contents in one domain cannot interact with those in another because of Same Origin Policies (SOPs). OBS supports CORS rules that allow the resources in OBS to be requested by other domains.

+

You can call ObsClient.setBucketCors to set CORS rules for a bucket. The configured CORS rules follow the principle of new ones overwriting old ones.

+
+

Restrictions

  • To configure CORS for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketCORS in IAM or PutBucketCORS in a bucket policy).
+
+

Method

obsclient.setBucketCors(final SetBucketCorsRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetBucketCorsRequest

+

Yes

+

Request parameters for setting a CORS rule. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketCorsRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

bucketCors

+

BucketCors

+

Yes

+

Explanation:

+

List of CORS rules of a bucket. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + +
Table 3 BucketCors

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

rules

+

List<BucketCorsRule>

+

Yes

+

Explanation:

+

List of CORS rules of a bucket. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 BucketCorsRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

No

+

Explanation:

+

CORS rule ID.

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

allowedMethod

+

List<String>

+

Yes

+

Explanation:

+

The allowed HTTP methods for a cross-origin request, indicating the operation types for buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

allowedOrigin

+

List<String>

+

Yes

+

Explanation:

+

The origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

allowedHeader

+

List<String>

+

No

+

Explanation:

+

The allowed cross-origin request headers. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

maxAgeSeconds

+

int

+

No

+

Explanation:

+

Duration your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each bucket CORS rule can contain only one maxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds.

+

Default value:

+

100

+

exposeHeader

+

List<String>

+

No

+

Explanation:

+

The CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to the list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 5 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures CORS rules for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketCors;
+import com.obs.services.model.BucketCorsRule;
+import com.obs.services.model.DeleteObjectsRequest;
+import com.obs.services.model.DeleteObjectsResult;
+import com.obs.services.model.KeyAndVersion;
+import java.util.ArrayList;
+import java.util.List;
+public class SetBucketCors001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            //Configure CORS rules.
+            BucketCors cors = new BucketCors();
+            List<BucketCorsRule> rules = new ArrayList<BucketCorsRule>();
+            BucketCorsRule rule = new BucketCorsRule();
+            ArrayList<String> allowedOrigin = new ArrayList<String>();
+            // Specify the origin of the cross-origin request.
+            allowedOrigin.add( "http://www.a.com");
+            allowedOrigin.add( "http://www.b.com");
+            rule.setAllowedOrigin(allowedOrigin);
+            ArrayList<String> allowedMethod = new ArrayList<String>();
+            // Specify the request method, which can be GET, PUT, DELETE, POST, or HEAD.
+            allowedMethod.add("GET");
+            allowedMethod.add("HEAD");
+            allowedMethod.add("PUT");
+            rule.setAllowedMethod(allowedMethod);
+            ArrayList<String> allowedHeader = new ArrayList<String>();
+            // Specify whether headers specified in Access-Control-Request-Headers in the OPTIONS request can be used.
+            allowedHeader.add("x-obs-header");
+            rule.setAllowedHeader(allowedHeader);
+            ArrayList<String> exposeHeader = new ArrayList<String>();
+            // Specify response headers that users can access using application programs.
+            exposeHeader.add("x-obs-expose-header");
+            rule.setExposeHeader(exposeHeader);
+            // Specify the browser's cache time of the returned results of OPTIONS requests for specific resources, in seconds.
+            rule.setMaxAgeSecond(10);
+            rules.add(rule);
+            cors.setRules(rules);
+            obsClient.setBucketCors("examplebucket", cors);
+            System.out.println("setBucketCors successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketCors failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketCors failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1403.html b/docs/obs_3rd_party/java_sdk/obs_21_1403.html new file mode 100644 index 000000000..23cf1ce3c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1403.html @@ -0,0 +1,310 @@ + + +

Obtaining a CORS Rule

+

Function

CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, website scripts and contents in one origin cannot interact with those in another due to SOPs. OBS supports CORS, allowing the resources in OBS to be requested across origins.

+

This API returns the CORS configuration of a bucket.

+
+

Restrictions

  • To obtain the CORS configuration of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketCORS in IAM or GetBucketCORS in a bucket policy).
+
+

Method

obsclient.getBucketCors(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining a CORS rule. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + +
Table 3 BucketCors

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

rules

+

List<BucketCorsRule>

+

Yes

+

Explanation:

+

List of CORS rules of a bucket. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 4 BucketCorsRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

No

+

Explanation:

+

CORS rule ID.

+

Value range:

+

The value must contain 1 to 255 characters.

+

Default value:

+

None

+

allowedMethod

+

List<String>

+

Yes

+

Explanation:

+

The allowed HTTP methods for a cross-origin request, indicating the operation types for buckets and objects.

+

Value range:

+

The following HTTP methods are supported:

+
  • GET
  • PUT
  • HEAD
  • POST
  • DELETE
+

Default value:

+

None

+

allowedOrigin

+

List<String>

+

Yes

+

Explanation:

+

The origin from which the requests can access the bucket.

+

Restrictions:

+

Domain name of the origin. Each origin can contain only one wildcard character (*), for example, https://*.vbs.example.com.

+

Default value:

+

None

+

allowedHeader

+

List<String>

+

No

+

Explanation:

+

The allowed cross-origin request headers. Only CORS requests matching the allowed headers are valid.

+

Restrictions:

+

Each header can contain only one wildcard character (*). Spaces, ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+

maxAgeSeconds

+

int

+

No

+

Explanation:

+

Duration your client can cache the response for a cross-origin request.

+

Restrictions:

+

Each bucket CORS rule can contain only one maxAgeSeconds.

+

Value range:

+

An integer greater than or equal to 0, in seconds.

+

Default value:

+

100

+

exposeHeader

+

List<String>

+

No

+

Explanation:

+

The CORS-allowed additional headers in the response. These headers provide additional information to clients. By default, your browser can only access headers Content-Length and Content-Type. If your browser needs to access other headers, add them to the list of the allowed additional headers.

+

Restrictions:

+

Spaces, wildcard characters (*), ampersands (&), colons (:), and less-than signs (<) are not allowed.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the CORS configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketCors;
+import com.obs.services.model.BucketCorsRule;
+public class GetBucketCors001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain the CORS rules.
+            BucketCors cors = obsClient.getBucketCors("examplebucket");
+            for(BucketCorsRule rule : cors.getRules()){
+                System.out.println("Id:" + rule.getId());
+                System.out.println("MaxAgeSecond:" + rule.getMaxAgeSecond());
+                System.out.println("AllowedHeader:" + rule.getAllowedHeader());
+                System.out.println("AllowedOrigin:" + rule.getAllowedOrigin());
+                System.out.println("AllowedMethod:" + rule.getAllowedMethod());
+                System.out.println("ExposeHeader:" + rule.getExposeHeader());
+            }
+            System.out.println("getBucketCors successfully");
+        } catch (ObsException e) {
+            System.out.println("getBucketCors failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketCors failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1404.html b/docs/obs_3rd_party/java_sdk/obs_21_1404.html new file mode 100644 index 000000000..9ea1b7ad7 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1404.html @@ -0,0 +1,199 @@ + + +

Deleting a CORS Rule

+

Function

CORS is a browser-standard mechanism defined by the W3C. It allows a web client in one origin to interact with resources in another. For general web page requests, website scripts and contents in one origin cannot interact with those in another due to SOPs. OBS supports CORS, allowing the resources in OBS to be requested across origins.

+

This API deletes the CORS rules of a bucket.

+
+

Restrictions

  • To delete the CORS configuration of a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketCORS in IAM or PutBucketCORS in a bucket policy).
+
+

Method

obsclient.deleteBucketCors(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters for deleting a CORS rule. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes CORS rules of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteBucketCors001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete CORS rules.
+            obsClient.deleteBucketCors("examplebucket");
+            System.out.println("deleteBucketCors successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteBucketCors failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteBucketCors failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1500.html b/docs/obs_3rd_party/java_sdk/obs_21_1500.html new file mode 100644 index 000000000..c16e042de --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1500.html @@ -0,0 +1,15 @@ + + +

Logging

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1501.html b/docs/obs_3rd_party/java_sdk/obs_21_1501.html new file mode 100644 index 000000000..198e8b6eb --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1501.html @@ -0,0 +1,15 @@ + + +

Overview

+

OBS allows you to configure access logging for buckets. After the configuration, access to buckets will be recorded in logs. These logs will be saved in specific buckets in OBS.

+

You can enable OBS logging for bucket analysis or audit purposes. With access logs, a bucket owner can analyze the characteristics, types, or trends of requests sent to the bucket.

+

With logging enabled, OBS automatically logs access requests for the bucket and writes the generated log files into a specified bucket.

+

You need to specify a bucket for storing log files when enabling logging for a bucket. Log files can be stored in any bucket you own in the region where the logged bucket is, including the logged bucket itself.

+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1502.html b/docs/obs_3rd_party/java_sdk/obs_21_1502.html new file mode 100644 index 000000000..dbbcd1c05 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1502.html @@ -0,0 +1,724 @@ + + +

Configuring Logging for a Bucket

+

Function

This API enables logging for a bucket (source) and configures another bucket (target) to store the log files. When a bucket is created, logging is not enabled by default. You can call this API to enable logging for the bucket. With logging enabled, a log message is generated for each operation on the bucket. Multiple log messages are packed into a file. The target bucket for storing log files must be specified when logging is enabled. It can be the bucket logging is enabled for, or any other bucket you have access to. If you specify another bucket for storing logs, the bucket must be in the same region as the logged bucket. You can also specify access permissions and name prefixes for log files.

+
+

Restrictions

  • The source and target buckets must be in the same region.
  • A bucket in the Warm or Cold storage class cannot be used as a target bucket.
  • OBS creates log files and uploads them to the bucket. Before enabling logging for a bucket, you need to create an IAM agency to delegate OBS to upload log files to the specified bucket.
  • To configure logging for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketLogging in IAM or PutBucketLogging in a bucket policy).
+
+

Method

obsClient.setBucketLogging(final SetBucketLoggingRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetBucketLoggingRequest

+

Yes

+

Explanation:

+

Request parameters for configuring logging for a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketLoggingRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Name of the source bucket.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

loggingConfiguration

+

BucketLoggingConfiguration

+

Yes

+

Explanation:

+

Bucket logging configurations. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 BucketLoggingConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

agency

+

String

+

Yes if you configure bucket logging

+

Explanation:

+

Name of the IAM agency created by the owner of the target bucket for OBS.

+

You can select an existing IAM agency or create one.

+

Restrictions:

+

By default, the IAM agency only requires the PutObject permission to upload logs to the target bucket. If default encryption is enabled for the target bucket, the agency also requires the KMS Administrator permission in the region where the target bucket is located.

+

Default value:

+

None

+

targetBucketName

+

String

+

No

+

Explanation:

+

Name of the bucket for storing log files.

+

Restrictions:

+
  • This bucket must be in the same region as the bucket with logging enabled.
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

logfilePrefix

+

String

+

No

+

Explanation:

+

Name prefix for log files stored in the target bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

targetGrantsList

+

List<GrantAndPermission>

+

No

+

Explanation:

+

Permission information list of grantees, which defines grantees and their permissions for log files. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 5.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 6.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 7 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 9 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Enabling Bucket Logging

This example configures logging for bucket examplebucket, with your agency as the agency, targetprefix as the prefix for generated log files, and targetbucketname as the bucket for storing log files.

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketLoggingConfiguration;
+public class SetBucketLogging001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Enable bucket logging.
+            BucketLoggingConfiguration config = new BucketLoggingConfiguration();
+           // Set an agency. You need to create one on IAM.
+            config.setAgency("your agency");
+            config.setTargetBucketName("targetbucketname");
+            config.setLogfilePrefix("targetprefix");
+            obsClient.setBucketLogging("examplebucket", config);
+            System.out.println("setBucketLogging successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketLogging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketLogging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

Code Example: Granting the Read Permission on a Log Object

This example configures logging for bucket examplebucket, with your agency as the agency, targetprefix as the prefix for generated log files, and targetbucketname as the bucket for storing log files, and then grants all users the read permission for the logs.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketLoggingConfiguration;
+import com.obs.services.model.GrantAndPermission;
+import com.obs.services.model.GroupGrantee;
+import com.obs.services.model.Permission;
+public class SetBucketLogging002
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Configure access to logs.
+            String targetBucket = "targetbucketname";
+             // Configure logging for the bucket.
+            BucketLoggingConfiguration config = new BucketLoggingConfiguration();
+           // Set an agency. You need to create one on IAM.
+            config.setAgency("your agency");
+            config.setTargetBucketName(targetBucket);
+            config.setLogfilePrefix("prefix");
+            // Grant all users the READ permission for the logs.
+            GrantAndPermission grant1 = new GrantAndPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
+            config.setTargetGrants(new GrantAndPermission[]{grant1});
+            obsClient.setBucketLogging("examplebucket", config);
+            System.out.println("setBucketLogging successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketLogging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketLogging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Disabling Bucket Logging

This example disables the logging for bucket examplebucket by clearing the logging configurations of the bucket using ObsClient.setBucketLogging.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketLoggingConfiguration;
+public class SetBucketLogging003
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Leave the logging configurations in blank.
+            obsClient.setBucketLogging("examplebucket", new BucketLoggingConfiguration());
+            System.out.println("setBucketLogging successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketLogging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketLogging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1503.html b/docs/obs_3rd_party/java_sdk/obs_21_1503.html new file mode 100644 index 000000000..7dc204cef --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1503.html @@ -0,0 +1,454 @@ + + +

Obtaining the Logging Configuration of a Bucket

+

Function

This API returns the logging configuration of a bucket.

+
+

Restrictions

  • To obtain the logging configuration of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketLogging in IAM or GetBucketLogging in a bucket policy).
+
+

Method

obsClient.getBucketLogging(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters for obtaining the logging configurations of a bucket. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 BucketLoggingConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

agency

+

String

+

Yes if you configure bucket logging

+

Explanation:

+

Name of the IAM agency created by the owner of the target bucket for OBS.

+

You can select an existing IAM agency or create one.

+

Restrictions:

+

By default, the IAM agency only requires the PutObject permission to upload logs to the target bucket. If default encryption is enabled for the target bucket, the agency also requires the KMS Administrator permission in the region where the target bucket is located.

+

Default value:

+

None

+

targetBucketName

+

String

+

No

+

Explanation:

+

Name of the bucket for storing log files.

+

Restrictions:

+
  • This bucket must be in the same region as the bucket with logging enabled.
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

logfilePrefix

+

String

+

No

+

Explanation:

+

Name prefix for log files stored in the target bucket.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

targetGrantsList

+

List<GrantAndPermission>

+

No

+

Explanation:

+

Permission information list of grantees, which defines grantees and their permissions for log files. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 4 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 5.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 8.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 6.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 7.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 7 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+
+

Code Examples

This example returns the logging configuration of bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketLoggingConfiguration;
+public class GetBucketLogging001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // View the bucket logging configuration.
+            BucketLoggingConfiguration config = obsClient.getBucketLogging("examplebucket");
+            System.out.println("TargetBucketName:" + config.getTargetBucketName());
+            System.out.println("LogfilePrefix:" + config.getLogfilePrefix());
+            System.out.println("getBucketLogging successfully");
+        } catch (ObsException e) {
+            System.out.println("getBucketLogging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketLogging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1600.html b/docs/obs_3rd_party/java_sdk/obs_21_1600.html new file mode 100644 index 000000000..a8426d16b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1600.html @@ -0,0 +1,19 @@ + + +

Static Website Hosting

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1601.html b/docs/obs_3rd_party/java_sdk/obs_21_1601.html new file mode 100644 index 000000000..6770e99a0 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1601.html @@ -0,0 +1,15 @@ + + +

Overview

+

To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configure static website hosting for your bucket.

+

After this, when third-party users access your websites, they actually access the objects in your bucket in OBS.

+

When using static website hosting, you can configure request redirection to redirect specific or all requests.

+

For more information about the application scenarios of static website hosting, see:

+ +
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1602.html b/docs/obs_3rd_party/java_sdk/obs_21_1602.html new file mode 100644 index 000000000..cc5494ee2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1602.html @@ -0,0 +1,1472 @@ + + +

Hosting Website Files in a Bucket

+

Function

To host your static website on OBS, you can upload static website files to your bucket as objects, configure the public read permission for the objects, and then configure static website hosting for your bucket. After this, when third-party users access your website, they are accessing the objects in your bucket.

+
+

Restrictions

  • To upload an object, you must be the bucket owner or have the required permission (obs:object:PutObject in IAM or PutObject in a bucket policy).
+
  • To configure an ACL for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketAcl in IAM or PutBucketAcl in a bucket policy).
+
+

Method

  1. Uploading an object:

    obsClient.putObject(PutObjectRequest request)

    +
  2. Configuring an object ACL:

    obsClient.setObjectAcl(SetObjectAclRequest acl)

    +
+
+

Request Parameters for Uploading an Object

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

PutObjectRequest

+

Yes

+

Explanation:

+

Request parameters for uploading an object. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 PutObjectRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

metadata

+

ObjectMetadata

+

No

+

Explanation:

+

Object metadata. For details, see Table 19.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

ACL that can be pre-defined when an object is created. Refer to Table 12 to choose the option you need.

+

Value range:

+
  • To use a pre-defined ACL, see Table 21 for the available options.
  • To use a user-defined ACL, see Table 12 to configure the required parameters.
+

Default value:

+

None

+

sseKmsHeader

+

SseKmsHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 7.

+

Default value:

+

None

+

sseCHeader

+

SseCHeader

+

No

+

Explanation:

+

Server-side encryption header. For details, see Table 8.

+

Default value:

+

None

+

input

+

java.io.InputStream

+

No

+

Explanation:

+

Data stream of the object to be uploaded.

+

Default value:

+

None

+

file

+

java.io.File

+

No

+

Explanation:

+

File stream of the object to be uploaded.

+

Default value:

+

None

+

extensionPermissionMap

+

Map<ExtensionObjectPermissionEnum, Set<String>>

+

No

+

Explanation:

+

A permission map for granting bucket ACL permissions to one or more accounts. ExtensionObjectPermissionEnum specifies the permissions to grant, and Set<String> describes the list of account IDs (indicated by domain_id) the granted permissions apply to.

+

Value range:

+ +

Default value:

+

None

+

expires

+

int

+

No

+

Explanation:

+

Expiration time of the object. The calculation starts from the time when the object was last modified. Once the object expires, it is automatically deleted.

+

Restrictions:

+

This parameter can be configured only during object upload and cannot be modified by calling a metadata API.

+

Value range:

+

An integer greater than 0, in days.

+

Default value:

+

None

+

progressListener

+

ProgressListener

+

No

+

Explanation:

+

Upload progress. For details, see Table 3.

+

encodeHeaders

+

boolean

+

No

+

Explanation:

+

Whether to enable OBS to automatically encode request headers.

+

Value range:

+

true: Encoding with SDK is enabled.

+

false: Encoding with SDK is disabled.

+

Default value:

+

true

+
+
+ +
+ + + + + + + + + + + +
Table 3 ProgressListener

Method

+

Return Value Type

+

Mandatory (Yes/No)

+

Description

+

progressChanged

+

void

+

Yes

+

Explanation:

+

Used for obtaining the progress. For details, see Table 4.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + +
Table 4 progressChanged

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

status

+

ProgressStatus

+

Yes

+

Explanation:

+

Progress data. For details, see Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 5 ProgressStatus

Method

+

Return Value Type

+

Description

+

getAverageSpeed()

+

double

+

Average transmission rate.

+

getInstantaneousSpeed()

+

double

+

Instantaneous transmission rate.

+

getTransferPercentage()

+

int

+

Transmission progress, in percentage.

+

getNewlyTransferredBytes()

+

long

+

Number of the newly transmitted bytes.

+

getTransferredBytes()

+

long

+

Number of bytes that have been transmitted.

+

getTotalBytes()

+

long

+

Number of the bytes to be transmitted.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 ExtensionObjectPermissionEnum

Constant

+

Description

+

GRANT_READ

+

Grants a specific tenant the permissions to read the object and object metadata.

+

GRANT_READ_ACP

+

Grants a specific tenant the permissions to obtain the object ACL.

+

GRANT_WRITE_ACP

+

Grants a specific tenant the permissions to write the object ACL.

+

GRANT_FULL_CONTROL

+

Grants a specific tenant the permissions to read the content, metadata, and ACL of the object and write the object ACL.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 7 SseKmsHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

encryption

+

ServerEncryption

+

Yes

+

Explanation:

+

SSE-KMS is used for encrypting objects on the server side.

+

Value range:

+

kms. For details, see Table 9.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only KMS is supported.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

kmsKeyId

+

String

+

No

+

Explanation:

+

ID of the KMS master key when SSE-KMS is used.

+

Value range:

+

Valid value formats are as follows:

+
  1. regionID:domainID:key/key_id
  2. key_id
+

In the preceding formats:

+
  • regionID indicates the ID of the region where the key is used.
  • domainID indicates the ID of the account that the key is for. To obtain it, see How Do I Get My Account ID and User ID?
  • key_id indicates the ID of the key created on Data Encryption Workshop (DEW).
+

Default value:

+
  • If this parameter is not specified, the default master key will be used.
  • If there is no such a default master key, OBS will create one and use it by default.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 SseCHeader

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

algorithm

+

ServerAlgorithm

+

Yes

+

Explanation:

+

SSE-C is used for encrypting objects on the server side.

+

Value range:

+

AES256, indicating AES is used to encrypt the object in SSE-C. For details, see Table 11.

+

Default value:

+

None

+

sseAlgorithm

+

SSEAlgorithmEnum

+

No

+

Explanation:

+

Encryption algorithm.

+

Restrictions:

+

Only AES256 is supported.

+

Value range:

+

See Table 10.

+

Default value:

+

None

+

sseCKey

+

byte[]

+

Yes

+

Explanation:

+

Key used for encrypting the object when SSE-C is used, in byte[] format.

+

Default value:

+

None

+

sseCKeyBase64

+

String

+

No

+

Explanation:

+

Base64-encoded key used for encrypting the object when SSE-C is used.

+

Default value:

+

None

+
+
+ +
+ + + + + + + +
Table 9 ServerEncryption

Constant

+

Default Value

+

OBS_KMS

+

kms

+
+
+ +
+ + + + + + + + + + +
Table 10 SSEAlgorithmEnum

Constant

+

Default Value

+

KMS

+

kms

+

AES256

+

AES256

+
+
+ +
+ + + + + + + +
Table 11 ServerAlgorithm

Constant

+

Default Value

+

AES256

+

AES256

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 12 AccessControlList

Parameter

+

Type

+

Mandatory (Yes/No)

+

Type

+

owner

+

Owner

+

No

+

Explanation:

+

Bucket owner information. For details, see Table 13.

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+

grants

+

Set<GrantAndPermission>

+

No

+

Explanation:

+

Grantee information. For details, see Table 14.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 13 Owner

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

id

+

String

+

Yes

+

Explanation:

+

Account (domain) ID of the bucket owner.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the owner.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 14 GrantAndPermission

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantee

+

GranteeInterface

+

Yes

+

Explanation:

+

Grantees (users or user groups). For details, see Table 16.

+

permission

+

Permission

+

Yes

+

Explanation:

+

Permissions to grant.

+

Value range:

+

See Table 15.

+

Default value:

+

None

+

delivered

+

boolean

+

No

+

Explanation:

+

Whether the bucket ACL is applied to all objects in the bucket.

+

Value range:

+

true: The bucket ACL is applied to all objects in the bucket.

+

false: The bucket ACL is not applied to any objects in the bucket.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Table 15 Permission

Constant

+

Default Value

+

Description

+

PERMISSION_READ

+

READ

+

Read permission.

+

A grantee with this permission for a bucket can obtain the list of objects, multipart uploads, bucket metadata, and object versions in the bucket.

+

A grantee with this permission for an object can obtain the object content and metadata.

+

PERMISSION_WRITE

+

WRITE

+

Write permission.

+

A grantee with this permission for a bucket can upload, overwrite, and delete any object or part in the bucket.

+

This permission is not available for objects.

+

PERMISSION_READ_ACP

+

READ_ACP

+

Permission to read an ACL.

+

A grantee with this permission can obtain the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

PERMISSION_WRITE_ACP

+

WRITE_ACP

+

Permission to modify an ACL.

+

A grantee with this permission can update the ACL of a bucket or object.

+

A bucket or object owner has this permission for their bucket or object by default.

+

This permission allows the grantee to change the access control policies, meaning the grantee has full control over a bucket or object.

+

PERMISSION_FULL_CONTROL

+

FULL_CONTROL

+

Full control access, including read and write permissions for a bucket and its ACL, or for an object and its ACL.

+

A grantee with this permission for a bucket has READ, WRITE, READ_ACP, and WRITE_ACP permissions for the bucket.

+

A grantee with this permission for an object has READ, READ_ACP, and WRITE_ACP permissions for the object.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 16 GranteeInterface

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

CanonicalGrantee

+

CanonicalGrantee

+

Yes

+

Explanation:

+

Grantee (user) information. For details, see Table 17.

+

GroupGrantee

+

GroupGrantee

+

Yes

+

Explanation:

+

Grantee (user group) information.

+

Value range:

+

See Table 18.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 17 CanonicalGrantee

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

grantId

+

String

+

Yes if Type is set to GranteeUser

+

Explanation:

+

Account (domain) ID of the grantee.

+

Value range:

+

To obtain the account ID, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+

displayName

+

String

+

No

+

Explanation:

+

Account name of the grantee.

+

Value range:

+

To obtain the account name, see How Do I Get My Account ID and User ID?

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 18 GroupGrantee

Constant

+

Description

+

ALL_USERS

+

All users.

+

AUTHENTICATED_USERS

+

Authorized users. This constant is deprecated.

+

LOG_DELIVERY

+

Log delivery group. This constant is deprecated.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 19 ObjectMetadata

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

contentLength

+

Long

+

No

+

Explanation:

+

Object size.

+

Restrictions:

+
  • The object size in a single upload ranges from 0 to 5 GB.
  • To upload files larger than 5 GB, multipart uploads should be used.
+

Default value:

+

If this parameter is not specified, the SDK automatically calculates the size of the object.

+

contentType

+

String

+

No

+

Explanation:

+

MIME type of the object file. MIME type is a standard way of describing a data type and is used by the browser to decide how to display data.

+

Value range:

+

See What Is Content-Type (MIME)?

+

Default value:

+

If this parameter is not specified, the SDK determines the file type based on the suffix of the object name and assigns a value to the parameter. For example, if the suffix of the object name is .xml, the object is an application/xml file. If the suffix is .html, the object is a text/html file.

+

contentEncoding

+

String

+

No

+

Explanation:

+

Content-Encoding header in the response. It specifies which encoding is applied to the object.

+

Default value:

+

None

+

contentDisposition

+

String

+

No

+

Explanation:

+

Provides a default file name for the requested object. When the object with the default file name is being downloaded or accessed, the content is displayed as part of a web page in the browser or as an attachment in a download dialog box.

+

Default value:

+

None

+

cacheControl

+

String

+

No

+

Explanation:

+

Cache-Control header in the response. It specifies the cache behavior of the web page when an object is downloaded.

+

Default value:

+

None

+

contentLanguage

+

String

+

No

+

Explanation:

+

Language or language combination for visitors to customize and use. For details, see the definition of ContentLanguage in the HTTP protocol.

+

Default value:

+

None

+

expires

+

String

+

No

+

Explanation:

+

The time a cached web page object expires.

+

Restrictions:

+

The time must be in the GMT format.

+

Default value:

+

None

+

contentMd5

+

String

+

No

+

Explanation:

+

Base64-encoded MD5 value of the file data. It is provided for the OBS server to verify data integrity. The OBS server will compare this MD5 value with the MD5 value calculated based on the file data. If the two values are not the same, HTTP status code 400 is returned.

+

Restrictions:

+
  • The MD5 value of the file must be Base64 encoded.
  • If the MD5 value is not specified, the OBS server will not verify the MD5 value of the object.
+

Value range:

+

Base64-encoded 128-bit MD5 value of the request body calculated according to RFC 1864.

+

Example: n58IG6hfM7vqI4K0vnWpog==

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

No

+

Explanation:

+

Storage class of an object that can be specified at object creation. If you do not specify this header, the object inherits the storage class of the bucket.

+

Value range:

+

See Table 20.

+

Default value:

+

None

+

webSiteRedirectLocation

+

String

+

No

+

Explanation:

+

If the bucket is configured with website hosting, the request for obtaining the object can be redirected to another object in the bucket or an external URL. This parameter specifies the address the request for the object is redirected to.

+

The request is redirected to an object anotherPage.html in the same bucket:

+

WebsiteRedirectLocation:/anotherPage.html

+

The request is redirected to an external URL http://www.example.com/:

+

WebsiteRedirectLocation:http://www.example.com/

+

Restrictions:

+
  • The value must start with a slash (/), http://, or https:// and cannot exceed 2 KB.
  • OBS only supports redirection for objects in the root directory of a bucket.
+

Default value:

+

None

+

nextPosition

+

long

+

No

+

Explanation:

+

Start position for the next append upload.

+

Value range:

+

0 to the object length, in bytes.

+

Default value:

+

None

+

appendable

+

boolean

+

No

+

Explanation:

+

Whether the object is appendable.

+

Value range:

+

true: The object is appendable.

+

false: The object is not appendable.

+

Default value:

+

None

+

userMetadata

+

Map<String, Object>

+

No

+

Explanation:

+

User-defined metadata of the object. To define it, you can add a header starting with x-obs-meta- in the request. In Map, the String key indicates the name of the user-defined metadata that starts with x-obs-meta-, and the Object value indicates the value of the user-defined metadata. To obtain the user-defined metadata of an object, use ObsClient.getObjectMetadata. For details, see Obtaining Object Metadata.

+

Restrictions:

+
  • An object can have multiple pieces of metadata. The size of the metadata cannot exceed 8 KB in total.
  • When you call ObsClient.getObject to download an object, its user-defined metadata will also be downloaded.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + +
Table 20 StorageClassEnum

Constant

+

Default Value

+

Description

+

STANDARD

+

STANDARD

+

Standard storage class

+

WARM

+

WARM

+

Warm storage class.

+

COLD

+

COLD

+

Cold storage class.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Table 21 Pre-defined ACL

Constant

+

Description

+

AccessControlList.REST_CANNED_PRIVATE

+

Private read/write.

+

A bucket or object can only be accessed by its owner.

+

AccessControlList.REST_CANNED_PUBLIC_READ

+

Public read.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, bucket metadata, and object versions in the bucket.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE

+

Public read/write.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart uploads, upload parts, assemble parts, copy parts, and abort multipart upload tasks.

+

If this permission is granted on an object, anyone can read the content and metadata of the object.

+

AccessControlList.REST_CANNED_PUBLIC_READ_DELIVERED

+

Public read on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart tasks, and bucket metadata, and can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_PUBLIC_READ_WRITE_DELIVERED

+

Public read/write on a bucket as well as objects in the bucket.

+

If this permission is granted on a bucket, anyone can read the object list, multipart uploads, and bucket metadata, and can upload or delete objects, initiate multipart upload tasks, upload parts, assemble parts, copy parts, and abort multipart uploads. They can also read the content and metadata of the objects in the bucket.

+

This permission cannot be granted on objects.

+

AccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL

+

If this permission is granted on an object, only the bucket and object owners have the full control over the object.

+

By default, if you upload an object to a bucket owned by another user, the bucket owner does not have the permissions on your object. After you grant this permission to the bucket owner, the bucket owner can have full control over your object.

+

For example, if user A uploads object x to user B's bucket, user B does not have the control over object x. If user A sets bucket-owner-full-control for object x, user B then has the control over object x.

+
+
+
+

Request Parameters for Setting an Object ACL

+
+ + + + + + + + + + + +
Table 22 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetObjectAclRequest

+

Yes

+

Explanation:

+

Request parameters for setting an object ACL. For details, see Table 23.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 23 SetObjectAclRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

objectKey

+

String

+

Yes

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

versionId

+

String

+

No

+

Explanation:

+

Object version ID.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

acl

+

AccessControlList

+

No

+

Explanation:

+

An ACL specified for the object. You can use either a pre-defined or a user-defined ACL.

+

Value range:

+
  • To use a pre-defined ACL, see Table 21 for the available options.
  • To use a user-defined ACL, see Table 12 to configure the required parameters.
+

Default value:

+

AccessControlList.REST_CANNED_PRIVATE

+
+
+
+

Responses for Uploading an Object

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 24 PutObjectResult

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

Response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+

storageClass

+

StorageClassEnum

+

Explanation:

+

Object storage class. If the storage class is Standard, leave this parameter blank.

+

Value range:

+

See Table 20.

+

Default value:

+

None

+

versionId

+

String

+

Explanation:

+

Object version ID. If versioning is enabled for the bucket, the object version number will be returned.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

etag

+

String

+

Explanation:

+

ETag of an object, which is a Base64-encoded 128-bit MD5 digest. ETag is the unique identifier of the object content. It can be used to determine whether the object content is changed. For example, if the ETag is A when an object is uploaded and is B when the object is downloaded, the object content is changed. The ETag reflects changes only to the contents of the object, not its metadata. An object created by an upload or copy operation has a unique ETag.

+

Restrictions:

+

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

+

Value range:

+

The value must contain 32 characters.

+

Default value:

+

None

+

objectKey

+

String

+

Explanation:

+

Object name. An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

bucketName

+

String

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses for Setting an Object ACL

+
+ + + + + + + + + + + + + +
Table 25 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures static website hosting for bucket examplebucket by specifying the MIME type and setting the object ACL to public read.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.AccessControlList;
+import com.obs.services.model.ObjectMetadata;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Sample code is as follows:
+            // Upload an object and set the MIME type for the object.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("test.html");
+            request.setFile(new File("localfile.html"));
+            ObjectMetadata metadata = new ObjectMetadata();
+            metadata.setContentType("text/html");
+            request.setMetadata(metadata);
+            obsClient.putObject(request);
+            // Set the object ACL to public read.
+            obsClient.setObjectAcl("examplebucket", "test.html", AccessControlList.REST_CANNED_PUBLIC_READ);
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

In this code example, you can use https://bucketname.your-endpoint/test.html to access the hosted file in the browser.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1603.html b/docs/obs_3rd_party/java_sdk/obs_21_1603.html new file mode 100644 index 000000000..58d7787e2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1603.html @@ -0,0 +1,780 @@ + + +

Configuring Static Website Hosting

+

Function

You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+
  • Redirecting all requests to another website
  • Redirecting specific requests to another website
+

This API configures static website hosting for a bucket.

+
+

Restrictions

  • Periods (.) should be avoided in the target bucket name, or there may be certificate verification failures on the client when you use HTTPS for access.
  • The request body of the website configuration cannot exceed 10 KB.
  • To configure static website hosting for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketWebsite in IAM or PutBucketWebsite in a bucket policy).
+
+

Method

obsClient.setBucketWebsite(final SetBucketWebsiteRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetBucketWebsiteRequest

+

Yes

+

Explanation:

+

Request parameters for configuring website hosting. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketWebsiteRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Value range:

+

The value must contain 3 to 63 characters.

+

websiteConfig

+

WebsiteConfiguration

+

Yes

+

Explanation:

+

Static website hosting configurations. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 WebsiteConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

suffix

+

String

+

No

+

Explanation:

+

Suffix that is appended to the request for a directory. For example, if the suffix is index.html and you request samplebucket/images/, the returned data will be for the object named images/index.html in the bucket samplebucket.

+

Restrictions:

+
  • key, suffix, and routeRules must be used together and they cannot be used with redirectAllRequestsTo.
  • When key, suffix, and routeRules are used together, routeRules can be left blank.
  • If you configure key, suffix, and routeRules, they must not be all left blank.
+

Value range:

+

This parameter can neither be left blank nor contain slashes (/).

+

Default value:

+

None

+

key

+

String

+

No

+

Explanation:

+

Object name to use when a 4XX error occurs. This parameter specifies the web page to display when an error occurs.

+

Restrictions:

+
  • key, suffix, and routeRules must be used together and they cannot be used with redirectAllRequestsTo.
  • When key, suffix, and routeRules are used together, routeRules can be left blank.
  • If you configure key, suffix, and routeRules, they must not be all left blank.
+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

routeRules

+

List<RouteRule>

+

No

+

Explanation:

+

List of routing rules. For details, see Table 6.

+

Restrictions:

+
  • key, suffix, and routeRules must be used together and they cannot be used with redirectAllRequestsTo.
  • When key, suffix, and routeRules are used together, routeRules can be left blank.
  • If you configure key, suffix, and routeRules, they must not be all left blank.
+

Default value:

+

None

+

redirectAllRequestsTo

+

RedirectAllRequest

+

No

+

Explanation:

+

Redirection rules for all requests. For details, see Table 4.

+

Restrictions:

+
  • key, suffix, and routeRules must be used together and they cannot be used with redirectAllRequestsTo.
  • If you configure redirectAllRequestsTo, it must not be left blank.
+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 RedirectAllRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

hostName

+

String

+

Yes

+

Explanation:

+

Host name used for redirection, for example, www.example.com.

+

Restrictions:

+

The host name must comply with the host name rules.

+

Default value:

+

None

+

protocol

+

ProtocolEnum

+

No

+

Explanation:

+

Protocol used for redirection.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 ProtocolEnum

Constant

+

Default Value

+

Description

+

HTTP

+

http

+

HTTP protocol used for redirection.

+

HTTPS

+

https

+

HTTPS protocol used for redirection.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 RouteRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

condition

+

RouteRuleCondition

+

No

+

Explanation:

+

Conditions of a redirection rule. For details, see Table 7.

+

redirect

+

Redirect

+

Yes

+

Explanation:

+

Details about the redirection. For details, see Table 8.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 RouteRuleCondition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

keyPrefixEquals

+

String

+

No

+

Explanation:

+

Object name prefix for the redirection to take effect. If the name prefix of the requested object is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, to redirect the requests for the object ExamplePage.html, set keyPrefixEquals to ExamplePage.html.

+

Restrictions:

+

This parameter cannot be used together with httpErrorCodeReturnedEquals.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpErrorCodeReturnedEquals

+

String

+

No

+

Explanation:

+

HTTP error code for the redirection to take effect. If there is an error, and the error code returned is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, if you want to redirect requests to NotFound.html when HTTP error code 404 is returned, set httpErrorCodeReturnedEquals to 404 in RouteRuleCondition, and set replaceKeyWith to NotFound.html in Redirect.

+

Restrictions:

+

This parameter cannot be used together with keyPrefixEquals.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Redirect

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

Protocol

+

ProtocolEnum

+

No

+

Explanation:

+

Protocol used for redirection.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

hostName

+

String

+

No

+

Explanation:

+

Host name used for redirection.

+

Default value:

+

None

+

replaceKeyPrefixWith

+

String

+

No

+

Explanation:

+

Object name prefix used in the redirection request.

+

Restrictions:

+

This parameter cannot be used together with replaceKeyWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

replaceKeyWith

+

String

+

No

+

Explanation:

+

Object name used in the redirection request.

+

Restrictions:

+

This parameter cannot be used together with replaceKeyPrefixWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpRedirectCode

+

String

+

No

+

Explanation:

+

HTTP status code in the response to the redirect request.

+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 9 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Example: Configuring the Default Home Page and Error Pages

This example configures the default homepage and error pages for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.WebsiteConfiguration;
+public class SetBucketWebsite001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Sample code is as follows:
+            WebsiteConfiguration config = new WebsiteConfiguration();
+            // Configure the default homepage.
+            config.setSuffix("index.html");
+            // Configure the error pages.
+            config.setKey("error.html");
+            obsClient.setBucketWebsite("examplebucket", config);
+            System.out.println("setBucketWebsite successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketWebsite failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketWebsite failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Configuring a Redirection Rule

This example configures a redirection rule for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ProtocolEnum;
+import com.obs.services.model.Redirect;
+import com.obs.services.model.RouteRule;
+import com.obs.services.model.RouteRuleCondition;
+import com.obs.services.model.WebsiteConfiguration;
+public class SetBucketWebsite002
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Sample code is as follows:
+            WebsiteConfiguration config = new WebsiteConfiguration();
+            // Configure the default homepage.
+            config.setSuffix("index.html");
+            // Configure the error pages.
+            config.setKey("error.html");
+            RouteRule rule = new RouteRule();
+            Redirect r = new Redirect();
+            r.setHostName("www.example.com");
+            r.setHttpRedirectCode("305");
+            r.setRedirectProtocol(ProtocolEnum.HTTP);
+            r.setReplaceKeyPrefixWith("replacekeyprefix");
+            rule.setRedirect(r);
+            RouteRuleCondition condition = new RouteRuleCondition();
+            condition.setHttpErrorCodeReturnedEquals("404");
+            condition.setKeyPrefixEquals("keyprefix");
+            rule.setCondition(condition);
+            config.getRouteRules().add(rule);
+            obsClient.setBucketWebsite("examplebucket", config);
+            System.out.println("setBucketWebsite successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketWebsite failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketWebsite failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+

Code Example: Configuring Redirection for All Requests

This example configures redirection of all requests for bucket examplebucket.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ProtocolEnum;
+import com.obs.services.model.RedirectAllRequest;
+import com.obs.services.model.WebsiteConfiguration;
+public class SetBucketWebsite003
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Sample code is as follows:
+            WebsiteConfiguration config = new WebsiteConfiguration();
+            RedirectAllRequest redirectAll = new RedirectAllRequest();
+            redirectAll.setHostName("www.example.com");
+            redirectAll.setRedirectProtocol(ProtocolEnum.HTTP);
+            config.setRedirectAllRequestsTo(redirectAll);
+            obsClient.setBucketWebsite("examplebucket", config);
+            System.out.println("setBucketWebsite successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketWebsite failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketWebsite failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1604.html b/docs/obs_3rd_party/java_sdk/obs_21_1604.html new file mode 100644 index 000000000..f9574b761 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1604.html @@ -0,0 +1,476 @@ + + +

Obtaining Static Website Hosting Configurations

+

Function

You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+
  • Redirecting all requests to another website
  • Redirecting specific requests to another website
+

This API returns the static website hosting configurations of the bucket.

+
+

Restrictions

  • To obtain the static website hosting configurations of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketWebsite in IAM or GetBucketWebsite in a bucket policy).
+
+

Method

obsClient.getBucketWebsite(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 3 WebsiteConfiguration

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

suffix

+

String

+

No

+

Explanation:

+

Suffix that is appended to the request for a directory. For example, if the suffix is index.html and you request samplebucket/images/, the returned data will be for the object named images/index.html in the bucket samplebucket.

+

Value range:

+

This parameter can neither be left blank nor contain slashes (/).

+

Default value:

+

None

+

key

+

String

+

No

+

Explanation:

+

Object name to use when a 4XX error occurs. This parameter specifies the web page to display when an error occurs.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

redirectAllRequestsTo

+

RedirectAllRequest

+

No

+

Explanation:

+

Redirection rules for all requests. For details, see Table 4.

+

routeRules

+

List<RouteRule>

+

No

+

Explanation:

+

List of routing rules. For details, see Table 6.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 4 RedirectAllRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

hostName

+

String

+

Yes

+

Explanation:

+

Host name used for redirection, for example, www.example.com.

+

Restrictions:

+

The host name must comply with the host name rules.

+

Default value:

+

None

+

protocol

+

ProtocolEnum

+

No

+

Explanation:

+

Protocol used for redirection.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + +
Table 5 ProtocolEnum

Constant

+

Default Value

+

Description

+

HTTP

+

http

+

HTTP protocol used for redirection.

+

HTTPS

+

https

+

HTTPS protocol used for redirection.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 6 RouteRule

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

condition

+

RouteRuleCondition

+

No

+

Explanation:

+

Conditions of a redirection rule. For details, see Table 7.

+

redirect

+

Redirect

+

Yes

+

Explanation:

+

Details about the redirection. For details, see Table 8.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 7 RouteRuleCondition

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

keyPrefixEquals

+

String

+

No

+

Explanation:

+

Object name prefix for the redirection to take effect. If the name prefix of the requested object is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, to redirect the requests for the object ExamplePage.html, set keyPrefixEquals to ExamplePage.html.

+

Restrictions:

+

This parameter cannot be used together with httpErrorCodeReturnedEquals.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpErrorCodeReturnedEquals

+

String

+

No

+

Explanation:

+

HTTP error code for the redirection to take effect. If there is an error, and the error code returned is the same as the value specified for this parameter, the redirection rule takes effect.

+

For example, if you want to redirect requests to NotFound.html when HTTP error code 404 is returned, set httpErrorCodeReturnedEquals to 404 in RouteRuleCondition, and set replaceKeyWith to NotFound.html in Redirect.

+

Restrictions:

+

This parameter cannot be used together with keyPrefixEquals.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 8 Redirect

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

Protocol

+

ProtocolEnum

+

No

+

Explanation:

+

Protocol used for redirection.

+

Value range:

+

See Table 5.

+

Default value:

+

None

+

hostName

+

String

+

No

+

Explanation:

+

Host name used for redirection.

+

Default value:

+

None

+

replaceKeyPrefixWith

+

String

+

No

+

Explanation:

+

Object name prefix used in the redirection request.

+

Restrictions:

+

This parameter cannot be used together with replaceKeyWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

replaceKeyWith

+

String

+

No

+

Explanation:

+

Object name used in the redirection request.

+

Restrictions:

+

This parameter cannot be used together with replaceKeyPrefixWith.

+

Value range:

+

The value must contain 1 to 1,024 characters.

+

Default value:

+

None

+

httpRedirectCode

+

String

+

No

+

Explanation:

+

HTTP status code in the response to the redirect request.

+

Default value:

+

None

+
+
+
+

Code Examples

This example returns the website configuration of bucket examplebucket using obsClient.getBucketWebsite.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.RouteRule;
+import com.obs.services.model.WebsiteConfiguration;
+public class GetBucketWebsite001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // View the website configuration of the bucket.
+            WebsiteConfiguration config = obsClient.getBucketWebsite("examplebucket");
+            System.out.println("Key:" + config.getKey());
+            System.out.println("Suffix:" + config.getSuffix());
+            for(RouteRule rule : config.getRouteRules()){
+                System.out.println("rule:" +rule);
+            }
+            System.out.println("getBucketWebsite successfully");
+        } catch (ObsException e) {
+            System.out.println("getBucketWebsite failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketWebsite failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1605.html b/docs/obs_3rd_party/java_sdk/obs_21_1605.html new file mode 100644 index 000000000..ccf4208d6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1605.html @@ -0,0 +1,202 @@ + + +

Deleting Static Website Hosting Configurations

+

Function

You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:

+
  • Redirecting all requests to another website
  • Redirecting specific requests to another website
+

This API deletes the static website hosting configurations of a bucket.

+
+

Restrictions

  • To delete the static website hosting configurations of a bucket, you must be the bucket owner or have the required permission (obs:bucket:DeleteBucketWebsite in IAM or DeleteBucketWebsite in a bucket policy).
+
+

Method

obsClient.deleteBucketWebsite(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes the website configuration of bucket examplebucket using obsClient.deleteBucketWebsite.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteBucketWebsite001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete the website configuration of the bucket.
+            obsClient.deleteBucketWebsite("examplebucket");
+            System.out.println("deleteBucketWebsite successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteBucketWebsite failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteBucketWebsite failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1700.html b/docs/obs_3rd_party/java_sdk/obs_21_1700.html new file mode 100644 index 000000000..de75f4637 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1700.html @@ -0,0 +1,17 @@ + + +

Bucket Tag Management

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1701.html b/docs/obs_3rd_party/java_sdk/obs_21_1701.html new file mode 100644 index 000000000..67f990afd --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1701.html @@ -0,0 +1,17 @@ + + +

Overview

+

Tags are used to identify and classify OBS buckets.

+

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis.

+

For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name.

+

In this manner, the costs of the application can be analyzed using tags in SDRs.

+

For details about the application scenarios of bucket tags, see:

+ +

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1702.html b/docs/obs_3rd_party/java_sdk/obs_21_1702.html new file mode 100644 index 000000000..ca42df166 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1702.html @@ -0,0 +1,313 @@ + + +

Configuring Tags for a Bucket

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs of the application can be analyzed using tags in SDRs.

+

This API adds tags to a bucket.

+
+

Restrictions

  • A bucket can have a maximum of 10 tags.
  • To configure tags for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketTagging in IAM or PutBucketTagging in a bucket policy).
+
+

Method

obsClient.setBucketTagging(final SetBucketTaggingRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

SetBucketTaggingRequest

+

Yes

+

Explanation:

+

Request parameters for setting bucket tags. For details, see Table 2.

+
+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 2 SetBucketTaggingRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+

bucketTagInfo

+

BucketTagInfo

+

Yes

+

Explanation:

+

Bucket tag information. For details, see Table 3.

+
+
+ +
+ + + + + + + + + + + +
Table 3 BucketTagInfo

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

tagSet

+

TagSet

+

Yes

+

Explanation:

+

Tag set. For details, see Table 4.

+
+
+ +
+ + + + + + + + + + + +
Table 4 TagSet

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

tags

+

List<Tag>

+

Yes

+

Explanation:

+

Tag list. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 Tag

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

String

+

Yes

+

Explanation:

+

Tag key.

+

Restrictions:

+
  • The tag key in the same bucket must be unique.
  • You can define tags or select the ones predefined on TMS.
  • The key must contain 1 to 128 characters.
  • Unicode is supported.
  • Tag keys cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+

value

+

String

+

Yes

+

Explanation:

+

Tag value.

+

Restrictions:

+
  • Tag values can be duplicated or left blank.
  • The value must contain 0 to 255 characters.
  • Unicode is supported.
  • Tag values cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 6 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example configures tags for bucket examplebucket using ObsClient.setBucketTagging.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketTagInfo;
+public class SetBucketTagging001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Configure tags for the bucket.
+            BucketTagInfo bucketTagInfo = new BucketTagInfo();
+            BucketTagInfo.TagSet tagSet = new BucketTagInfo.TagSet();
+            tagSet.addTag("tag1", "value1");
+            tagSet.addTag("tag2", "value2");
+            bucketTagInfo.setTagSet(tagSet);
+            obsClient.setBucketTagging("examplebucket", bucketTagInfo);
+            System.out.println("setBucketTagging successfully");
+        } catch (ObsException e) {
+            System.out.println("setBucketTagging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("setBucketTagging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1703.html b/docs/obs_3rd_party/java_sdk/obs_21_1703.html new file mode 100644 index 000000000..ce4920fdc --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1703.html @@ -0,0 +1,277 @@ + + +

Obtaining Bucket Tags

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs of the application can be analyzed using tags in SDRs.

+

This API returns the tags of a bucket.

+
+

Restrictions

  • To obtain the bucket tags, you must be the bucket owner or have the required permission (obs:bucket:GetBucketTagging in IAM or GetBucketTagging in a bucket policy).
+
+

Method

obsClient.getBucketTagging(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + + + + + +
Table 3 BucketTagInfo

Parameter

+

Type

+

Description

+

tagSet

+

TagSet

+

Explanation:

+

Tag set. For details, see Table 4.

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+ +
+ + + + + + + + + +
Table 4 TagSet

Parameter

+

Type

+

Description

+

tags

+

List<Tag>

+

Explanation:

+

Tag list. For details, see Table 5.

+
+
+ +
+ + + + + + + + + + + + + + + + +
Table 5 Tag

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

key

+

String

+

Yes

+

Explanation:

+

Tag key.

+

Restrictions:

+
  • The tag key in the same bucket must be unique.
  • You can define tags or select the ones predefined on TMS.
  • The key must contain 1 to 128 characters.
  • Unicode is supported.
  • Tag keys cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+

value

+

String

+

Yes

+

Explanation:

+

Tag value.

+

Restrictions:

+
  • Tag values can be duplicated or left blank.
  • The value must contain 0 to 255 characters.
  • Unicode is supported.
  • Tag values cannot start or end with a space and cannot contain commas (,), asterisks (*), vertical bars (|), slashes (/), less-than signs (<), greater-than signs (>), equal signs (=), backslashes (\), or ASCII control characters (0x00 to 0x1F). Tag keys and values must be URL encoded before being sent to a server.
  • The value is case-sensitive.
+

Default value:

+

None

+
+
+
+

Code Examples

This example returns tags of bucket examplebucket using obsClient.getBucketTagging.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.BucketTagInfo;
+public class GetBucketTagging001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Obtain bucket tags.
+            BucketTagInfo bucketTagInfo = obsClient.getBucketTagging("examplebucket");
+            for(BucketTagInfo.TagSet.Tag tag : bucketTagInfo.getTagSet().getTags()){
+                System.out.println("\t" + tag.getKey() + ":" + tag.getValue());}
+            System.out.println("getBucketTagging successfully");
+        } catch (ObsException e) {
+            System.out.println("getBucketTagging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getBucketTagging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1704.html b/docs/obs_3rd_party/java_sdk/obs_21_1704.html new file mode 100644 index 000000000..d40c61980 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1704.html @@ -0,0 +1,201 @@ + + +

Deleting Bucket Tags

+

Function

If you add tags to a bucket, SDRs generated for the requests sent to this bucket will include these tags, so you can use the tags to classify SDRs for detailed cost analysis. For example, if you have an application that uploads its running data to a bucket, you can tag the bucket with the application name. In this manner, the costs of the application can be analyzed using tags in SDRs.

+

This API deletes the tags of a bucket.

+
+

Restrictions

  • To delete bucket tags, you must be the bucket owner or have the required permission (obs:bucket:DeleteBucketTagging in IAM or DeleteBucketTagging in a bucket policy).
+
+

Method

obsClient.deleteBucketTagging(final BaseBucketRequest request)

+
+

Request Parameters

+
+ + + + + + + + + + + +
Table 1 List of request parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

request

+

BaseBucketRequest

+

Yes

+

Explanation:

+

Request parameters related to basic bucket information. For details, see Table 2.

+
+
+ +
+ + + + + + + + + + + +
Table 2 BaseBucketRequest

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

bucketName

+

String

+

Yes

+

Explanation:

+

Bucket name.

+

Restrictions:

+
  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.-bucket.
    +
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.
+

Default value:

+

None

+
+
+
+

Responses

+
+ + + + + + + + + + + + + +
Table 3 Common response headers

Parameter

+

Type

+

Description

+

statusCode

+

int

+

Explanation:

+

HTTP status code.

+

Value range:

+

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response.

+

Default value:

+

None

+

responseHeaders

+

Map<String, Object>

+

Explanation:

+

HTTP response header list, composed of tuples. In a tuple, the String key indicates the name of the header, and the Object value indicates the value of the header.

+

Default value:

+

None

+
+
+
+

Code Examples

This example deletes tags of bucket examplebucket using ObsClient.deleteBucketTagging.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+public class DeleteBucketTagging001
+{
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is to be created.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Delete bucket tags.
+            obsClient.deleteBucketTagging("examplebucket");
+            System.out.println("deleteBucketTagging successfully");
+        } catch (ObsException e) {
+            System.out.println("deleteBucketTagging failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("deleteBucketTagging failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1900.html b/docs/obs_3rd_party/java_sdk/obs_21_1900.html new file mode 100644 index 000000000..def99f0bf --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1900.html @@ -0,0 +1,15 @@ + + +

Server-Side Encryption

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1901.html b/docs/obs_3rd_party/java_sdk/obs_21_1901.html new file mode 100644 index 000000000..a61a59741 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1901.html @@ -0,0 +1,18 @@ + + +

Overview

+

OBS provides server-side encryption for objects, so that they will be encrypted or decrypted when you upload them to or download them from a bucket.

+

The encryption and decryption happen on the server side.

+

There are different encryption methods for you to choose from.

+

With SSE-KMS, OBS uses the keys provided by Key Management Service (KMS) for server-side encryption. You can create custom keys for SSE-KMS encryption.

+

With SSE-C, OBS uses the keys and MD5 values of the keys provided by customers for server-side encryption.

+

When server-side encryption is used, the returned ETag value is not the object's MD5 value. OBS will verify the object's MD5 value as long as the upload request includes the Content-MD5 header, no matter whether server-side encryption is used or not.

+

When server-side encryption is used, you are advised to use HTTPS to transmit and receive data.

+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1902.html b/docs/obs_3rd_party/java_sdk/obs_21_1902.html new file mode 100644 index 000000000..a9668e7c0 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1902.html @@ -0,0 +1,77 @@ + + +

Server-Side Encryption APIs

+

The following table lists APIs related to server-side encryption:

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Method in OBS Java SDK

+

Description

+

Supported Encryption Type

+

ObsClient.putObject

+

Sets the encryption algorithm and key during object upload to enable server-side encryption.

+

SSE-KMS

+

SSE-C

+

ObsClient.getObject

+

Users with the KMS Administrator permission can directly download objects encrypted using KMS. During a download, the backend decrypts KMS-encrypted objects before returning them. (SSE-KMS)

+

Sets the decryption algorithm and key during object download to decrypt the object. (SSE-C)

+

SSE-KMS

+

SSE-C

+

ObsClient.copyObject

+
  1. Sets the decryption algorithm and key for decrypting the source object during object copy.
  2. Sets the encryption algorithm and key during object copy to enable the encryption algorithm for the target object.
+

SSE-KMS

+

SSE-C

+

ObsClient.getObjectMetadata

+

Sets the decryption algorithm and key when obtaining the object metadata to decrypt the object.

+

SSE-C

+

ObsClient.initiateMultipartUpload

+

Sets the encryption algorithm and key when initializing a multipart upload to enable server-side encryption for the final object generated.

+

SSE-KMS

+

SSE-C

+

ObsClient.uploadPart

+

Sets the encryption algorithm and key during multipart upload to enable server-side encryption for parts.

+

SSE-C

+

ObsClient.copyPart

+
  1. Sets the decryption algorithm and key for decrypting the source object during multipart copy.
  2. Sets the encryption algorithm and key during multipart copy to enable the encryption algorithm for the target part.
+

SSE-C

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_1903.html b/docs/obs_3rd_party/java_sdk/obs_21_1903.html new file mode 100644 index 000000000..6366afbc6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_1903.html @@ -0,0 +1,190 @@ + + +

Code Examples for Server-Side Encryption

+

Code Example: Encrypting (SSE-C) and Uploading an Object

The following code shows an example of encrypting an object with SSE-C before uploading it:

+
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
// Hard-coded or plaintext access keys (AK/SK) are risky. For security purposes, encrypt your access keys and store them in the configuration file or environment variables. In this example, access keys are stored in the environment variables for identity authentication. Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+// Obtain an AK/SK pair on the management console.
+String ak = System.getenv("ACCESS_KEY_ID");
+String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+// Create an ObsClient instance.
+ObsClient obsClient = new ObsClient(ak, sk, endPoint);
+
+PutObjectRequest request = new PutObjectRequest();
+request.setBucketName("bucketname");
+request.setObjectKey("objectname");
+request.setFile(new File("localfile"));
+
+HashMap<String, String> userHeaders = new HashMap<>();
+userHeaders.put("x-obs-server-side-encryption-customer-algorithm","AES256");
+//The key for encrypting objects when SSE-C is used. Its value is a Base64-encoded 256-bit key.
+userHeaders.put("x-obs-server-side-encryption-customer-key","your-encryption-customer-key");
+userHeaders.put("x-obs-server-side-encryption-customer-key-MD5",
+                    ServiceUtils.toBase64(ServiceUtils.computeMD5Hash(ServiceUtils.fromBase64("your-encryption-customer-key"))));            request.setUserHeaders(userHeaders);
+HeaderResponse response = obsClient.putObject(request);
+System.out.println("response:"+response.getRequestId());
+
+
+

Code Example: Decrypting and Downloading an Object

The following code shows an example of downloading an object encrypted with SSE-C:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.internal.utils.ServiceUtils;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SseCGetObject{
+    public static void main(String[] args) {
+        // Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK and store them in the configuration file or environment variables. In this example, the AK and SK are stored in environment variables for identity authentication.
+        //Before running the code in this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");        
+        // Create an ObsClient instance and use the permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use the temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Call APIs to perform operations, for example, downloading an encrypted object.
+            GetObjectRequest request=new GetObjectRequest("bucketname","objectname");
+            // Set the SSE-C decryption algorithm.
+            HashMap<String, String> userHeaders=new HashMap<>();
+            userHeaders.put("x-obs-server-side-encryption-customer-algorithm","AES256");
+            The header indicates the key used to encrypt objects in SSE-C mode. The header value is a Base64-encoded 256-bit key.
+            userHeaders.put("x-obs-server-side-encryption-customer-key","your-encryption-customer-key");
+            userHeaders.put("x-obs-server-side-encryption-customer-key-MD5",
+                    ServiceUtils.toBase64(ServiceUtils.computeMD5Hash(ServiceUtils.fromBase64("your-encryption-customer-key"))));
+            request.setUserHeaders(userHeaders);
+            ObsObject obsObject=obsClient.getObject(request);
+            // You can use other methods to read streams.
+            System.out.println(obsObject.getObjectContent());
+        }
+        catch(ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            Map<String, String> headers=e.getResponseHeaders();
+            if(headers!=null){
+                Check all map entries and print all headers with errors reported.
+                for(Map.Entry<String, String> header:headers.entrySet()){
+                    if(header.getKey().contains("error")){
+                        System.out.println(header.getKey()+":"+header.getValue());
+                    }
+                }
+            }
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2000.html b/docs/obs_3rd_party/java_sdk/obs_21_2000.html new file mode 100644 index 000000000..2b13c6c2f --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2000.html @@ -0,0 +1,19 @@ + + +

Troubleshooting

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2001.html b/docs/obs_3rd_party/java_sdk/obs_21_2001.html new file mode 100644 index 000000000..884932308 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2001.html @@ -0,0 +1,115 @@ + + +

HTTP Status Codes

+

The OBS server complies with the HTTP standard. After an API is called, the OBS server returns a standard HTTP status code. The following tables list the categories of HTTP status codes and the common HTTP status codes in OBS.

+
  • Categories of HTTP status codes +
    + + + + + + + + + + + + + + + + + + + +

    Category

    +

    Description

    +

    1XX

    +

    Informational response. A request is received by the server and the server requires the requester to continue the operation. This category is usually invisible to the client.

    +

    2XX

    +

    Success. The operation is received and processed successfully.

    +

    3XX

    +

    Redirection. Further operations to complete the request are required. This category is usually invisible to the client.

    +

    4XX

    +

    Client errors. The request contains a syntax error, or the request cannot be implemented.

    +

    5XX

    +

    Server errors. There is an error when the server is processing a request.

    +
    +
    +
  • Common HTTP status codes in OBS and their meanings +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    HTTP Status Code

    +

    Description

    +

    Possible Cause

    +

    400 Bad Request

    +

    The request parameter is incorrect.

    +
    • Invalid request parameter.
    • The consistency check fails after the client request carries MD5.
    • An invalid parameter is transferred when the SDK is used.
    • An invalid bucket name is used.
    +

    403 Forbidden

    +

    The access is denied.

    +
    • The signature carried in the request header does not match with the signature calculated by the OBS server. Generally, the error is caused by incorrect AK/SK.
    • The account does not have the permission to access the requested resource.
    • The account is in arrears.
    • The bucket space is insufficient when a quota is set for the bucket.
    • Invalid AK
    • The time difference between the client and the server is too large (the time on the machine where the client is located is not in sync with the time on the NTP server).
    +

    404 Not Found

    +

    The requested resource does not exist.

    +
    • The bucket does not exist.
    • The object does not exist.
    • The bucket policy configuration does not exist. For example, the bucket CORS configuration or bucket policy configuration does not exist.
    • The multipart upload does not exist.
    +

    405 Method Not Allowed

    +

    The request method is not supported.

    +

    The request method or feature is not supported in the region where the bucket is located.

    +

    408 Request Timeout

    +

    Request timed out.

    +

    The Socket connection between the server and client times out.

    +

    409 Conflict

    +

    Request conflicts occur.

    +
    • Buckets of the same name are created in different regions.
    • The bucket to delete is not empty.
    +

    500 Internal Server Error

    +

    An internal error occurs on the server side.

    +

    An internal error occurs on the server side.

    +

    503 Service Unavailable

    +

    The service is unavailable.

    +

    The server is inaccessible temporarily.

    +
    +
    +
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2002.html b/docs/obs_3rd_party/java_sdk/obs_21_2002.html new file mode 100644 index 000000000..a7a546774 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2002.html @@ -0,0 +1,746 @@ + + +

OBS Server-side Error Codes

+

If the OBS server encounters an error when processing a request, a response containing the error code and error description is returned. The following table lists details about each error code and HTTP status code.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

HTTP Status Code

+

Error Code

+

Error Message

+

Solution

+

301 Moved Permanently

+

PermanentRedirect

+

The requested bucket can be accessed only through the specified address. Send subsequent requests to the address.

+

Send the request to the returned redirection address.

+

301 Moved Permanently

+

WebsiteRedirect

+

The website request lacks bucketName.

+

Put the bucket name in the request and try again.

+

307 Moved Temporarily

+

TemporaryRedirect

+

Temporary redirection. If the DNS is updated, the request is redirected to the bucket.

+

The system automatically redirects the request or sends the request to the redirection address.

+

400 Bad Request

+

BadDigest

+

The specified value of Content-MD5 does not match the value received by OBS.

+

Check whether the MD5 value carried in the header is the same as that calculated by the message body.

+

400 Bad Request

+

BadDomainName

+

Invalid domain name.

+

Use a valid domain name.

+

400 Bad Request

+

BadRequest

+

Invalid request parameter.

+

Modify the parameter according to the error details returned in the message body.

+

400 Bad Request

+

CustomDomainAreadyExist

+

The configured domain already exists.

+

It has been configured and does not need to be configured again.

+

400 Bad Request

+

CustomDomainNotExist

+

The domain to be deleted does not exist.

+

The domain is not configured or has been deleted. You do not need to delete it.

+

400 Bad Request

+

EntityTooLarge

+

The size of the object uploaded using the POST method exceeds the upper limit.

+

Modify the conditions specified in the policy when posting the object or reduce the object size.

+

400 Bad Request

+

EntityTooSmall

+

The size of the object uploaded using the POST method does not reach the lower limit.

+

Modify the conditions specified in the policy when posting the object or increase the object size.

+

400 Bad Request

+

IllegalLocationConstraintException

+

A request without Location is sent for creating a bucket in a non-default region.

+

Send the bucket creation request to the default region, or send the request with the Location of the non-default region.

+

400 Bad Request

+

IncompleteBody

+

No complete request body is received due to network or other problems.

+

Upload the object again.

+

400 Bad Request

+

IncorrectNumberOfFilesInPost Request

+

Each POST request must contain one file to be uploaded.

+

Carry a file to be uploaded.

+

400 Bad Request

+

InvalidArgument

+

Invalid parameter.

+

Modify the parameter according to the error details in the message body.

+

400 Bad Request

+

InvalidBucket

+

The bucket to be accessed does not exist.

+

Try another bucket name.

+

400 Bad Request

+

InvalidBucketName

+

The bucket name specified in the request is invalid, which may have exceeded the maximum length, or contain special characters that are not allowed.

+

Try another bucket name.

+

400 Bad Request

+

InvalidEncryptionAlgorithmError

+

Incorrect encryption algorithm. The object cannot be decrypted due to incorrect encryption header carried when downloading the SSE-C encrypted object.

+

Carry the correct encryption header when downloading the object.

+

400 Bad Request

+

InvalidLocationConstraint

+

The specified Location in the bucket creation request is invalid or does not exist.

+

Correct the Location in the bucket creation request.

+

400 Bad Request

+

InvalidPart

+

One or more specified parts are not found. The parts may not be uploaded or the specified entity tags (ETags) do not match the parts' ETags.

+

Specify the correct parts and entity tags.

+

400 Bad Request

+

InvalidPartOrder

+

Parts are not listed in ascending order by part number.

+

Sort the parts in ascending order and assemble them again.

+

400 Bad Request

+

InvalidPolicyDocument

+

The content of the form does not meet the conditions specified in the policy document.

+

Modify the policy in the constructed form according to the error details in the message body and try again.

+

400 Bad Request

+

InvalidRedirectLocation

+

Invalid redirect location.

+

Specify the correct IP address.

+

400 Bad Request

+

InvalidRequest

+

Invalid request.

+

Modify the parameter according to the error details returned in the message body.

+

400 Bad Request

+

InvalidRequestBody

+

The request body is invalid. The request requires a message body but no message body is uploaded.

+

Upload the message body in the correct format.

+

400 Bad Request

+

InvalidTargetBucketForLogging

+

The delivery group has no ACL permission for the target bucket.

+

Configure the target bucket ACL and try again.

+

400 Bad Request

+

KeyTooLongError

+

The provided key is too long.

+

Use a shorter key.

+

400 Bad Request

+

KMS.DisabledException

+

The master key is disabled in server-side encryption with KMS-managed keys (SSE-KMS) mode.

+

Replace the key and try again, or contact with the technical support.

+

400 Bad Request

+

KMS.NotFoundException

+

The master key does not exist in SSE-KMS mode.

+

Retry with the correct master key.

+

400 Bad Request

+

MalformedACLError

+

The XML file you provided was not well-formed or did not validate against our format requirements.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedError

+

The XML format in the request is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedLoggingStatus

+

The XML format of Logging is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedPolicy

+

The bucket policy failed the check.

+

Modify the bucket policy according to the error details returned in the message body.

+

400 Bad Request

+

MalformedQuotaError

+

The Quota XML format is incorrect.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MalformedXML

+

An XML file of a configuration item is in incorrect format.

+

Use the correct XML format to retry.

+

400 Bad Request

+

MaxMessageLengthExceeded

+

Copying an object does not require a message body in the request.

+

Remove the message body and retry.

+

400 Bad Request

+

MetadataTooLarge

+

The size of the metadata header has exceeded the upper limit.

+

Reduce the size of the metadata header.

+

400 Bad Request

+

MissingRegion

+

No region contained in the request and no default region defined in the system.

+

Carry the region information in the request.

+

400 Bad Request

+

MissingRequestBodyError

+

An empty XML file is sent as a request.

+

Provide the correct XML file.

+

400 Bad Request

+

MissingRequiredHeader

+

A required header is missing in the request.

+

Provide the required header.

+

400 Bad Request

+

MissingSecurityHeader

+

A required header is missing in the request.

+

Provide the required header.

+

400 Bad Request

+

TooManyBuckets

+

You have attempted to create more buckets than allowed.

+

Delete some buckets and try again.

+

400 Bad Request

+

TooManyCustomDomains

+

Too many user accounts are configured.

+

Delete some user accounts and try again.

+

400 Bad Request

+

TooManyWrongSignature

+

The request is rejected due to high-frequency errors.

+

Replace AK and try again.

+

400 Bad Request

+

UnexpectedContent

+

The request requires a message body which is not carried by the client, or the request does not require a message body but the client carries the message body.

+

Try again according to the instruction.

+

400 Bad Request

+

AZRedundancyTypeNotSupported

+

The current region does not support buckets with this AZ redundancy.

+

Choose a type of AZ redundancy supported in the region.

+

400 Bad Request

+

UserKeyMustBeSpecified

+

This operation is only available to special users.

+

Contact the technical support.

+

403 Forbidden

+

AccessDenied

+

Access denied, because the request does not carry a date header or the header format is incorrect.

+

Provide a correct date header in the request.

+

403 Forbidden

+

AccessForbidden

+

Insufficient permission. No CORS rule is configured for the bucket or the CORS rule does not match.

+

Modify the CORS configuration of the bucket or send the matched OPTIONS request based on the CORS configuration of the bucket.

+

403 Forbidden

+

AllAccessDisabled

+

You have no permission to perform the operation. The bucket name is forbidden.

+

Change the bucket name.

+

403 Forbidden

+

DeregisterUserId

+

The user has been deregistered.

+

Top up or re-register.

+

403 Forbidden

+

InArrearOrInsufficientBalance

+

The subscriber owes fees or the account balance is insufficient, and the subscriber does not have the permission to perform an operation.

+

Top up the account.

+

403 Forbidden

+

InsufficientStorageSpace

+

Insufficient storage space.

+

If the quota is exceeded, increase quota or delete some objects.

+

403 Forbidden

+

InvalidAccessKeyId

+

The access key ID provided by the customer does not exist in the system.

+

Provide a correct access key ID.

+

403 Forbidden

+

RequestTimeTooSkewed

+

The request time and the server's time differ a lot.

+

Check whether the difference between the client time and the current time is too large.

+

403 Forbidden

+

SignatureDoesNotMatch

+

The provided signature in the request does not match the signature calculated by OBS.

+

Check your secret access key and signature calculation method.

+

403 Forbidden

+

Unauthorized

+

You have not been authenticated in real name.

+

Authenticate your real name and try again.

+

404 Not Found

+

NoSuchBucket

+

The specified bucket does not exist.

+

Create a bucket and perform the operation again.

+

404 Not Found

+

NoSuchBucketPolicy

+

No bucket policy exists.

+

Configure a bucket policy.

+

404 Not Found

+

NoSuchCORSConfiguration

+

No CORS configuration exists.

+

Configure CORS first.

+

404 Not Found

+

NoSuchCustomDomain

+

The requested user domain does not exist.

+

Set a user domain first.

+

404 Not Found

+

NoSuchKey

+

The specified key does not exist.

+

Upload the object first.

+

404 Not Found

+

NoSuchLifecycleConfiguration

+

The requested lifecycle rule does not exist.

+

Configure a lifecycle rule first.

+

404 Not Found

+

NoSuchUpload

+

The specified multipart upload does not exist. The upload ID does not exist or the multipart upload job has been aborted or completed.

+

Use the existing part or reinitialize the part.

+

404 Not Found

+

NoSuchVersion

+

The specified version ID does not match any existing version.

+

Use a correct version ID.

+

404 Not Found

+

NoSuchWebsiteConfiguration

+

The requested website does not exist.

+

Configure the website first.

+

405 Method Not Allowed

+

MethodNotAllowed

+

The specified method is not allowed against the requested resource.

+

The message "Specified method is not supported." is returned.

+

The method is not allowed.

+

408 Request Timeout

+

RequestTimeout

+

No read or write operation has been performed within the timeout period of the socket connection between the user and the server.

+

Check the network and try again, or contact technical support.

+

409 Conflict

+

BucketAlreadyExists

+

The requested bucket name already exists. The bucket namespace is shared by all users of OBS. Select another name and retry.

+

Try another bucket name.

+

409 Conflict

+

BucketAlreadyOwnedByYou

+

Your previous request for creating the named bucket succeeded and you already own it.

+

You do not need to create the bucket again.

+

409 Conflict

+

BucketNotEmpty

+

The bucket that you tried to delete is not empty.

+

Delete the objects in the bucket and then delete the bucket.

+

409 Conflict

+

FsObjectConflict

+

File upload or creation failed.

+

Check the file creation rule. For example, check whether you are overwriting files when overwrite is not allowed, or whether you are uploading a file to a file (taking this file as a directory) under POSIX semantics.

+

409 Conflict

+

OperationAborted

+

A conflicting operation is being performed on this resource. Retry later.

+

Try again later.

+

409 Conflict

+

ServiceNotSupported

+

The request method is not supported by the server.

+

Not supported by the server. Contact technical support.

+

411 Length Required

+

MissingContentLength

+

The HTTP header Content-Length is not provided.

+

Provide the Content-Length header.

+

412 Precondition Failed

+

PreconditionFailed

+

At least one of the specified preconditions is not met.

+

Modify according to the condition prompt in the returned message body.

+

416 Client Requested Range Not Satisfiable

+

InvalidRange

+

The requested range cannot be obtained.

+

Retry with the correct range.

+

500 Internal Server Error

+

InternalError

+

An internal error occurs. Retry later.

+

Contact the technical support.

+

501 Not Implemented

+

ServiceNotImplemented

+

The request method is not implemented by the server.

+

Not supported currently. Contact the technical support.

+

503 Service Unavailable

+

ServiceUnavailable

+

The server is overloaded or has internal errors.

+

Try again later or contact the technical support.

+

503 Service Unavailable

+

SlowDown

+

Too frequent requests. Reduce your request frequency.

+

Reduce your request frequency.

+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2003.html b/docs/obs_3rd_party/java_sdk/obs_21_2003.html new file mode 100644 index 000000000..f84a75144 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2003.html @@ -0,0 +1,38 @@ + + +

SDK Common Response Headers

+

After you successfully call an API in an instance of ObsClient, an instance of the HeaderResponse class (or of its sub-class) will be returned.

+

It contains information about HTTP/HTTPS response headers.

+

Sample code for processing public response headers:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+// Obtain an AK/SK pair on the management console.
+String ak = System.getenv("ACCESS_KEY_ID");
+String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+// Create an ObsClient instance.
+ObsClient obsClient = new ObsClient(ak, sk, endPoint);
+HeaderResponse response = obsClient.createBucket("bucketname");
+
+// Obtain the request ID from the common response headers.
+System.out.println("\t" + response.getRequestId());
+
+obsClient.close();
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2004.html b/docs/obs_3rd_party/java_sdk/obs_21_2004.html new file mode 100644 index 000000000..bcef9704d --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2004.html @@ -0,0 +1,87 @@ + + +

Log Analysis

+

How To Enable Logging

  1. Save the log4j2.xml file obtained from the OBS Java SDK package to the classpath root directory.
  2. Call Log4j2Configurator.setLogConfig to specify the save path of log4j2.xml directly.
+

You can obtain the default log configuration file log4j2.xml from the OBS Java SDK package, and then modify to customize the file.

+
+
+

Log Path

The log path of OBS Java SDK is specified in log4j2.xml. Logs are saved in the path represented by system variable user.dir of JDK by default. In general, there are three logs files as follows:

+ +
+ + + + + + + + + + + + + +

File Name

+

Description

+

OBS-SDK.interface_north.log

+

Northbound log file, which saves the logs about the communication between OBS Java SDK and third-party applications of users.

+

OBS-SDK.interface_south.log

+

Southbound log file, which saves the logs about the communication between OBS Java SDK and the OBS server.

+

OBS-SDK.access.log

+

Run log file of the OBS server.

+
+
+
+

Log Format

The SDK log format is: Log time|Thread number|Log level|Log content. The following are example logs:

+
#Southbound logs
+2017-08-21 17:40:07 133|main|INFO |HttpClient cost 157 ms to apply http request
+2017-08-21 17:40:07 133|main|INFO |Received expected response code: true
+2017-08-21 17:40:07 133|main|INFO |expected code(s): [200, 204].
+
+#Northbound logs
+2017-08-21 17:40:06 820|main|INFO |Storage|1|HTTP+XML|ObsClient||||2017-08-21 17:40:05|2017-08-21 17:40:06|||0|
+2017-08-21 17:40:07 136|main|INFO |Storage|1|HTTP+XML|setObjectAcl||||2017-08-21 17:40:06|2017-08-21 17:40:07|||0|
+2017-08-21 17:40:07 137|main|INFO |ObsClient [setObjectAcl] cost 312 ms
+
+

Log Level

When current logs cannot be used to troubleshoot system faults, you can change the log level to obtain more information. You can obtain the most information in TRACE logs and the least information in ERROR logs.

+

Log level description:

+
  • OFF: Close level. If this level is set, logging will be disabled.
  • TRACE: Trace level. If this level is set, all log information will be printed. This level is not recommended.
  • DEBUG: Debugging level. If this level is set, information about logs of the INFO level and above, HTTP/HTTPS request and response headers, and StringToSign information calculated by authentication algorithm will be printed.
  • INFO: Information level. If this level is set, information about logs of the WARN level and above, time consumed for each HTTP/HTTPS request, and time consumed for calling the ObsClient API will be printed.
  • WARN: Warning level. If this level is set, information about logs of the ERROR level and above, as well as information about some critical events (for example, the number of retry attempts exceeds the upper limit) will be printed.
  • ERROR: Error level. If this level is set, only error information will be printed.
+
+

How to Set

The following sample code shows how to set different levels for the southbound logs, northbound logs, and OBS server run logs. (For details about log configuration, see configuration file log4j2.xml.)

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
<!-- north log -->
+<Logger name="com.obs.services.AbstractClient" level="INFO" additivity="false">
+      <AppenderRef ref="NorthInterfaceLogAppender" />
+</Logger>
+        
+<!-- south log -->
+<Logger name="com.obs.services.internal.RestStorageService" level="WARN" additivity="false">
+       <AppenderRef ref="SouthInterfaceLogAppender" />
+</Logger>
+
+<!-- access log -->
+<Logger name="com.obs.log.AccessLogger" level="ERROR" additivity="false">
+        <AppenderRef ref="AccessLogAppender" />
+</Logger>
+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2005.html b/docs/obs_3rd_party/java_sdk/obs_21_2005.html new file mode 100644 index 000000000..4e5114652 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2005.html @@ -0,0 +1,13 @@ + + +

SDK Exceptions

+

SDK custom exceptions (ObsException), thrown by ObsClient, are inherited from class java.lang.RuntimeException. Exceptions are usually OBS server errors, including OBS error codes and error information. This facilitates users to locate problems and troubleshot faults.

+

ObsException contains the following error information:

+
  • ObsException.getResponseCode(): HTTP status code
  • ObsException.getErrorCode(): Error code returned by the OBS server
  • ObsException.getErrorMessage(): Error description returned by the OBS server
  • ObsException.getErrorRequestId(): Request ID returned by the OBS server
  • ObsException.getErrorHostId(): Requested server ID
  • ObsException.getResponseHeaders(): HTTP response headers
  • ObsException.printStackTrace(): Prints the detailed stack trace of an exception.
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2100.html b/docs/obs_3rd_party/java_sdk/obs_21_2100.html new file mode 100644 index 000000000..6aafc87b3 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2100.html @@ -0,0 +1,41 @@ + + +

FAQs

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2107.html b/docs/obs_3rd_party/java_sdk/obs_21_2107.html new file mode 100644 index 000000000..abf1e3925 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2107.html @@ -0,0 +1,12 @@ + + +

How Can I Set an Object to Be Accessible to Anonymous Users?

+

To do this, perform the following steps:

+
  1. Set the ACL to public read for the object by referring to Configuring an Object ACL.
  2. Obtain the URL of the object by referring to How Do I Obtain an Object URL? and provide it to anonymous users.
  3. An anonymous user can access the object by entering the URL on a browser.
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2109.html b/docs/obs_3rd_party/java_sdk/obs_21_2109.html new file mode 100644 index 000000000..98f080175 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2109.html @@ -0,0 +1,14 @@ + + +

What Is the Retry Mechanism of SDK?

+

SDK uses the maxErrorRetry parameter configured in Creating and Configuring an OBS Client to retry. The default value for retry times is 3. 0 to 5 is recommended.

+

If the network connection is abnormal or the server returns the 5XX error when an ObsClient API is called, the SDK performs an exponential backoff retry.

+
  • For ObsClient.putObject, when the data source is an InputStream other than FileInputStream, the SDK does not retry when an I/O exception occurs because the data stream cannot be re-read. The upper-layer application needs to retry.
  • When ObsClient.getObject is successfully called and ObsObject is returned, the SDK does not retry when an I/O exception occurs during data reading from ObsObject.getObjectContent because this situation is beyond the scope of the processing logic of the SDK. The upper-layer application needs to retry.
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2110.html b/docs/obs_3rd_party/java_sdk/obs_21_2110.html new file mode 100644 index 000000000..56b2a1d57 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2110.html @@ -0,0 +1,12 @@ + + +

How Do I Obtain the Static Website Access Address of a Bucket?

+

After a bucket is configured to work in static website hosting mode, you can use the following method to combine the static website access address of the bucket.

+

https://bucket name.static website hosting domain name

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2111.html b/docs/obs_3rd_party/java_sdk/obs_21_2111.html new file mode 100644 index 000000000..9559d8443 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2111.html @@ -0,0 +1,36 @@ + + +

How Do I Obtain an Object URL?

+

If the uploaded object is set to be read by anonymous users, anonymous users can download the object through the object URL directly. Methods to obtain the object URL are as follows:

+

Method 1: Query by calling the API. After an object is uploaded using the ObsClient API, PutObjectResult is returned. You can call getObjectUrl to obtain the URL of the uploaded object. The sample code is as follows:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+// Obtain an AK/SK pair on the management console.
+String ak = System.getenv("ACCESS_KEY_ID");
+String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+// Create an ObsClient instance.
+ObsClient obsClient = new ObsClient(ak, sk, endPoint);
+// Call putObject to upload the object and obtain the return result.
+PutObjectResult result = obsClient.putObject("bucketname", "objectname", new File("localfile"));
+// Read the URL of the uploaded object.
+System.out.println("\t" + result.getObjectUrl());
+
+
+

Method 2: Assemble the URL in the format of https://Bucket name.Domain name/Directory level/Object name.

+
  • If the object resides in the root directory of a bucket, its URL does not contain a directory level.
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2112.html b/docs/obs_3rd_party/java_sdk/obs_21_2112.html new file mode 100644 index 000000000..cd1ebfec4 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2112.html @@ -0,0 +1,13 @@ + + +

How to Improve the Speed of Uploading Large Files over the Public Network?

+

If a file exceeds 100 MB, you are advised to upload the file using multipart upload.

+

Multipart upload refers to splitting an object into multiple parts and uploading them separately. Each part is a contiguous portion of the object's data. You can upload parts in any sequence. A part can be reloaded after an upload failure, without affecting other parts. Uploading multiple parts of an object using multiple threads concurrently can greatly improve the transmission efficiency.

+

For code examples, see Multipart Upload.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2114.html b/docs/obs_3rd_party/java_sdk/obs_21_2114.html new file mode 100644 index 000000000..da7f439c1 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2114.html @@ -0,0 +1,13 @@ + + +

How Can I Perform a Multipart Upload?

+

In a multipart upload, you can specify a part of the file to be uploaded by performing the following steps:

+
  1. Initialize an instance of ObsClient based on the AK, SK, and endpoint.
  2. Specify the bucket name and object name to initialize InitiateMultipartUploadRequest. Call InitiateMultipartUploadRequest.setMetadata to specify the metadata of the object to be uploaded. Then, call ObsClient.initiateMultipartUpload to initiate a multipart upload task. A globally unique identifier (upload ID) for this task will be returned.
  3. Specify the bucket name and object name to initialize UploadPartRequest. Call UploadPartRequest.setUploadId to specify the upload ID to which the part to be uploaded corresponds. Call setPartNumber to specify the part number of the part. Call setFile to specify the large file to which the part belongs. Call setPartSize to specify the part size. Then, call ObsClient.uploadPart to upload the part. The ETag value of the uploaded part is returned.
  4. After all parts are uploaded, specify the bucket name, object name, uploadId, and partEtags to initialize a CompleteMultipartUploadRequest request. Then, call ObsClient.completeMultipartUpload to assemble parts.
+

For details, see Multipart Upload.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2115.html b/docs/obs_3rd_party/java_sdk/obs_21_2115.html new file mode 100644 index 000000000..4c6009b2e --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2115.html @@ -0,0 +1,13 @@ + + +

How Can I Perform a Download in Multipart Mode?

+

In a multipart download, you can specify the range of data to be downloaded. The procedure is as follows:

+
  1. You need to initialize an instance of ObsClient by using AK, SK, and endpoint.
  2. Specify the bucket name and object name to initialize GetObjectRequest. Call GetObjectRequest.setRangeStart and GetObjectRequest.setRangeEnd to set the start and end points of the object data to be downloaded.
  3. Call ObsClient.getObject to send the GetObjectRequest request in step 2 to download the data in multipart mode.
+

For details, see Downloading an Object - Range-Based.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2117.html b/docs/obs_3rd_party/java_sdk/obs_21_2117.html new file mode 100644 index 000000000..b0a34287b --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2117.html @@ -0,0 +1,13 @@ + + +

How Do I Confirm that an Upload is Successful If I Upload an Object to Overwrite an Existing Object with the Same Name in a Bucket?

+

After the upload is complete, you can call ObsClient.getObjectMetadata to obtain the size and last modification time of the newly uploaded object and compare them with those of the overwritten object.

+

If the sizes are the same and the last modification time of the new object is later than that of the overwritten object, the upload succeeded. Otherwise, the upload failed.

+

For details about how to call ObsClient.getObjectMetadata, see Obtaining Object Metadata.

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2118.html b/docs/obs_3rd_party/java_sdk/obs_21_2118.html new file mode 100644 index 000000000..0ad97776a --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2118.html @@ -0,0 +1,14 @@ + + +

How Do I Download an Encrypted Object Using a URL?

+

If the object is encrypted with SSE-KMS, the server automatically decrypts the object when you use the URL of the object to download it.

+

If the object is encrypted with SSE-C, you cannot access the object directly through a web browser because a request header is required for decryption. If you use code to download the encrypted object, configure the header by referring to Code Example: Downloading an Object Encrypted Using SSE-C.

+

Accessing a server-side encrypted object requires the HTTPS protocol.

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2119.html b/docs/obs_3rd_party/java_sdk/obs_21_2119.html new file mode 100644 index 000000000..57fea58b6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2119.html @@ -0,0 +1,100 @@ + + +

How Do I Generate an SSE-C Encryption Key?

+

Sample code of generating an SSE-C encryption key and its MD5 value:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class SseCTool {
+    public static void main(String[] args) {
+        // Below is an encryption key example. The key can be changed as needed, but it must be 32 characters long (a 256-bit string).
+        String keyString = System.getenv("ACCESS_KEY_ID");
+        // Compute the x-obs-server-side-encryption-customer-key header.
+        String customerKey = toBase64String(keyString.getBytes(Charset.forName("UTF-8")));
+        System.out.println("customer key is : " + customerKey);
+
+        // Compute the x-obs-server-side-encryption-customer-key-MD5 header.
+        String customerKeyMD5 = computeMD5(fromBase64(customerKey));
+        System.out.println("md5 for customer key is : " + customerKeyMD5);
+    }
+
+    // Compute the Base64 character string.
+    public static String toBase64String(byte[] data) {
+        java.util.Base64.Encoder encoder = java.util.Base64.getEncoder();
+        return new String(encoder.encode(data), Charset.forName("UTF-8"));
+    }
+
+    // Compute the MD5 character string.
+    public static String computeMD5(byte[] b64Data) {
+        try {
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            md5.update(b64Data);
+
+            byte[] byteArray = md5.digest();
+
+            return toBase64String(byteArray);
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+            return "";
+        }
+
+    }
+
+    public static byte[] fromBase64(String b64Data) {
+        java.util.Base64.Decoder decoder = java.util.Base64.getDecoder();
+        return decoder.decode(b64Data.getBytes(Charset.forName("UTF-8")));
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2121.html b/docs/obs_3rd_party/java_sdk/obs_21_2121.html new file mode 100644 index 000000000..94cd6427c --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2121.html @@ -0,0 +1,161 @@ + + +

Does the SDK Support Uploading, Downloading, or Copying Objects in a Batch?

+

No.

+

Currently, the SDK does not provide such APIs. You need to encapsulate the service codes for uploading, downloading, or copying objects in a batch by yourself. The procedure is as follows:

+
  1. List all objects to be uploaded, downloaded, or copied. For details about how to list objects to be downloaded, see Listing Objects.
  2. Call the API for uploading, downloading, or copying a single object for the listed objects.
+

Sample code:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
// Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID.
+// Obtain an AK/SK pair on the management console.
+String ak = System.getenv("ACCESS_KEY_ID");
+String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+final String bucketName = "bucketname";
+// Define the prefix of objects in a bucket.
+final String objectPre = "object/";
+// Folder to be uploaded
+final String localDirPath = "localDirPath";
+final List<File> list = new ArrayList<>();
+// Scan all objects in the folder.
+static void listFiles(File file){
+    File[] fs = file.listFiles();
+    assert fs != null;
+    if (fs.length < 1){
+        // If an empty folder needs to be uploaded, add it to the list.
+        list.add(file);
+    }else{
+        for (File f:fs){
+            if (f.isDirectory()){
+                listFiles(f);
+            }
+            if (f.isFile()){
+                // Add objects to be uploaded to the list.
+                list.add(f);
+            }
+        }
+    }
+}
+// Traverse the folder to be uploaded and obtain all objects to be uploaded.
+File file = new File(localDirPath);
+listFiles(file);
+
+// Create an instance of ObsClient.
+final ObsClient obsClient = new ObsClient(ak, sk, endPoint);
+
+// Initialize the thread pool.
+ExecutorService executorService = Executors.newFixedThreadPool(20);
+
+// Concurrently upload parts.
+for (File f:list){
+    executorService.execute(() -> {
+        if (f.isDirectory()){
+            // For empty folders, create empty folder objects in the bucket.
+            String remoteObjectKey = objectPre + f.getPath().substring(localDirPath.length() + 1) + "/";
+            obsClient.putObject(bucketName, remoteObjectKey, new ByteArrayInputStream(new byte[0]));
+        }else{
+            String remoteObjectKey = objectPre + f.getPath().substring(localDirPath.length() + 1);
+            obsClient.putObject(bucketName, remoteObjectKey, new File(f.getPath()));
+        }
+    });
+}
+
+// Wait until the upload is complete.
+executorService.shutdown();
+while (!executorService.isTerminated())
+{
+    try
+    {
+        executorService.awaitTermination(5, TimeUnit.SECONDS);
+    }
+    catch (InterruptedException e)
+    {
+        e.printStackTrace();
+    }
+}
+// Close ObsClient.
+try {
+    obsClient.close();
+} catch (IOException e) {
+    e.printStackTrace();
+}
+
+
+

You can use multiple threads to concurrently upload, download, and copy data to improve efficiency.

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2124.html b/docs/obs_3rd_party/java_sdk/obs_21_2124.html new file mode 100644 index 000000000..995210242 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2124.html @@ -0,0 +1,1624 @@ + + +

What Is Content-Type (MIME)?

+

Multipurpose Internet Mail Extensions (MIME) type is a standard way of describing a data type. The MIME type is passed in the Content-Type header.

+

If you do not specify Content-Type when uploading an object, the SDK determines the object type based on the suffix of the specified object name and automatically assigns a value to Content-Type.

+
+

Content-Type

Content-Type indicates the type of data to send or receive and determine the form and encoding method browsers will use to display data (mainly custom client files or media files). If no content type is specified, the type will be generated based on the file name extension. If there is no extension, the content type is application/octet-stream by default.

+
+

Common Content Types

The commonly used content types are given in the table below.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 List of common content types

File Name Extension

+

Content-Type(Mime-Type)

+

File Name Extension

+

Content-Type(Mime-Type)

+

.* (binary stream, unknown file type)

+

application/octet-stream

+

.tif

+

image/tiff

+

.a11

+

application/x-a11

+

.acp

+

audio/x-mei-aac

+

.ai

+

application/postscript

+

.aif

+

audio/aiff

+

.aifc

+

audio/aiff

+

.aiff

+

audio/aiff

+

.anv

+

application/x-anv

+

.apk

+

application/vnd.android.package-archive

+

.asa

+

text/asa

+

.asf

+

video/x-ms-asf

+

.asp

+

text/asp

+

.asx

+

video/x-ms-asf

+

.au

+

audio/basic

+

.avi

+

video/avi

+

.awf

+

application/vnd.adobe.workflow

+

.biz

+

text/xml

+

.bmp

+

application/x-bmp

+

.bot

+

application/x-bot

+

.c4t

+

application/x-c4t

+

.c90

+

application/x-c90

+

.cal

+

application/x-cals

+

.cat

+

application/vnd.ms-pki.seccat

+

.cdf

+

application/x-netcdf

+

.cdr

+

application/x-cdr

+

.cel

+

application/x-cel

+

.cer

+

application/x-x509-ca-cert

+

.cg4

+

application/x-g4

+

.cgm

+

application/x-cgm

+

.cit

+

application/x-cit

+

.class

+

java/

+

.cml

+

text/xml

+

.cmp

+

application/x-cmp

+

.cmx

+

application/x-cmx

+

.cot

+

application/x-cot

+

.crl

+

application/pkix-crl

+

.crt

+

application/x-x509-ca-cert

+

.csi

+

application/x-csi

+

.css

+

text/css

+

.csv

+

text/csv

+

.cut

+

application/x-cut

+

.dbf

+

application/x-dbf

+

.dbm

+

application/x-dbm

+

.dbx

+

application/x-dbx

+

.dcd

+

text/xml

+

.dcx

+

application/x-dcx

+

.der

+

application/x-x509-ca-cert

+

.dgn

+

application/x-dgn

+

.dib

+

application/x-dib

+

.dll

+

application/x-msdownload

+

.doc

+

application/msword

+

.docx

+

application/vnd.openxmlformats-officedocument.wordprocessingml.document

+

.dot

+

application/msword

+

.dotx

+

application/vnd.openxmlformats-officedocument.wordprocessingml.template

+

.drw

+

application/x-drw

+

.dtd

+

text/xml

+

.dwf

+

Model/vnd.dwf

+

.dwf

+

application/x-dwf

+

.dwg

+

application/x-dwg

+

.dxb

+

application/x-dxb

+

.dxf

+

application/x-dxf

+

.edn

+

application/vnd.adobe.edn

+

.emf

+

application/x-emf

+

.eml

+

message/rfc822

+

.ent

+

text/xml

+

.epi

+

application/x-epi

+

.eps

+

application/x-ps

+

.eps

+

application/postscript

+

.etd

+

application/x-ebx

+

.exe

+

application/x-msdownload

+

.fax

+

image/fax

+

.fdf

+

application/vnd.fdf

+

.fif

+

application/fractals

+

.fo

+

text/xml

+

.frm

+

application/x-frm

+

.g4

+

application/x-g4

+

.gbr

+

application/x-gbr

+

.

+

application/x-

+

.gif

+

image/gif

+

.gl2

+

application/x-gl2

+

.gp4

+

application/x-gp4

+

.hgl

+

application/x-hgl

+

.hmr

+

application/x-hmr

+

.hpg

+

application/x-hpgl

+

.hpl

+

application/x-hpl

+

.hqx

+

application/mac-binhex40

+

.hrf

+

application/x-hrf

+

.hta

+

application/hta

+

.htc

+

text/x-component

+

.htm

+

text/html

+

.html

+

text/html

+

.htt

+

text/webviewhtml

+

.htx

+

text/html

+

.icb

+

application/x-icb

+

.ico

+

image/x-icon

+

.ico

+

application/x-ico

+

.iff

+

application/x-iff

+

.ig4

+

application/x-g4

+

.igs

+

application/x-igs

+

.iii

+

application/x-iphone

+

.img

+

application/x-img

+

.ins

+

application/x-internet-signup

+

.ipa

+

application/vnd.iphone

+

.isp

+

application/x-internet-signup

+

.IVF

+

video/x-ivf

+

.java

+

java/*

+

.jfif

+

image/jpeg

+

.jpe

+

image/jpeg

+

.jpe

+

application/x-jpe

+

.jpeg

+

image/jpeg

+

.jpg

+

image/jpeg

+

.jpg

+

application/x-jpg

+

.js

+

application/x-javascript

+

.jsp

+

text/html

+

.la1

+

audio/x-liquid-file

+

.lar

+

application/x-laplayer-reg

+

.latex

+

application/x-latex

+

.lavs

+

audio/x-liquid-secure

+

.lbm

+

application/x-lbm

+

.lmsff

+

audio/x-la-lms

+

.ls

+

application/x-javascript

+

.ltr

+

application/x-ltr

+

.m1v

+

video/x-mpeg

+

.m2v

+

video/x-mpeg

+

.m3u

+

audio/mpegurl

+

.m4e

+

video/mpeg4

+

.mac

+

application/x-mac

+

.man

+

application/x-troff-man

+

.math

+

text/xml

+

.mdb

+

application/msaccess

+

.mdb

+

application/x-mdb

+

.mfp

+

application/x-shockwave-flash

+

.mht

+

message/rfc822

+

.mhtml

+

message/rfc822

+

.mi

+

application/x-mi

+

.mid

+

audio/mid

+

.midi

+

audio/mid

+

.mil

+

application/x-mil

+

.mml

+

text/xml

+

.mnd

+

audio/x-musicnet-download

+

.mns

+

audio/x-musicnet-stream

+

.mocha

+

application/x-javascript

+

.mov

+

video/quicktime

+

.movie

+

video/x-sgi-movie

+

mp1

+

audio/mp1

+

.mp2

+

audio/mp2

+

.mp2v

+

video/mpeg

+

.mp3

+

audio/mp3

+

.mp4

+

video/mp4

+

.mpa

+

video/x-mpg

+

.mpd

+

application/vnd.ms-project

+

.mpe

+

video/x-mpeg

+

.mpeg

+

video/mpg

+

.mpg

+

video/mpg

+

.mpga

+

audio/rn-mpeg

+

.mpp

+

application/vnd.ms-project

+

.mps

+

video/x-mpeg

+

.mpt

+

application/vnd.ms-project

+

.mpv

+

video/mpg

+

.mpv2

+

video/mpeg

+

.mpw

+

application/vnd.ms-project

+

.mpx

+

application/vnd.ms-project

+

.mtx

+

text/xml

+

.mxp

+

application/x-mmxp

+

.net

+

image/pnetvue

+

.nrf

+

application/x-nrf

+

.nws

+

message/rfc822

+

.odc

+

text/x-ms-odc

+

.out

+

application/x-out

+

.p10

+

application/pkcs10

+

.p12

+

application/x-pkcs12

+

.p7b

+

application/x-pkcs7-certificates

+

.p7c

+

application/pkcs7-mime

+

.p7m

+

application/pkcs7-mime

+

.p7r

+

application/x-pkcs7-certreqresp

+

.p7s

+

application/pkcs7-signature

+

.pc5

+

application/x-pc5

+

.pci

+

application/x-pci

+

.pcl

+

application/x-pcl

+

.pcx

+

application/x-pcx

+

.pdf

+

application/pdf

+

.pdb

+

chemical/x-pdb

+

.pdx

+

application/vnd.adobe.pdx

+

.pfx

+

application/x-pkcs12

+

.pgl

+

application/x-pgl

+

.pic

+

application/x-pic

+

.pko

+

application/vnd.ms-pki.pko

+

.pl

+

application/x-perl

+

.plg

+

text/html

+

.pls

+

audio/scpls

+

.plt

+

application/x-plt

+

.png

+

image/png

+

.png

+

application/x-png

+

.pot

+

application/vnd.ms-powerpoint

+

.potx

+

application/vnd.openxmlformats-officedocument.presentationml.template

+

.ppa

+

application/vnd.ms-powerpoint

+

.ppm

+

application/x-ppm

+

.pps

+

application/vnd.ms-powerpoint

+

.ppsx

+

application/vnd.openxmlformats-officedocument.presentationml.slideshow

+

.ppt

+

application/vnd.ms-powerpoint

+

.ppt

+

application/x-ppt

+

. pptx

+

application/vnd.openxmlformats-officedocument.presentationml.presentation

+

.pr

+

application/x-pr

+

.prf

+

application/pics-rules

+

.prn

+

application/x-prn

+

.prt

+

application/x-prt

+

.ps

+

application/x-ps

+

.ps

+

application/postscript

+

.ptn

+

application/x-ptn

+

.pwz

+

application/vnd.ms-powerpoint

+

.r3t

+

text/vnd.rn-realtext3d

+

.ra

+

audio/vnd.rn-realaudio

+

.ram

+

audio/x-pn-realaudio

+

.ras

+

application/x-ras

+

.rat

+

application/rat-file

+

.rdf

+

text/xml

+

.rec

+

application/vnd.rn-recording

+

.red

+

application/x-red

+

.rgb

+

application/x-rgb

+

.rjs

+

application/vnd.rn-realsystem-rjs

+

.rjt

+

application/vnd.rn-realsystem-rjt

+

.rlc

+

application/x-rlc

+

.rle

+

application/x-rle

+

.rm

+

application/vnd.rn-realmedia

+

.rmf

+

application/vnd.adobe.rmf

+

.rmi

+

audio/mid

+

.rmj

+

application/vnd.rn-realsystem-rmj

+

.rmm

+

audio/x-pn-realaudio

+

.rmp

+

application/vnd.rn-rn_music_package

+

.rms

+

application/vnd.rn-realmedia-secure

+

.rmvb

+

application/vnd.rn-realmedia-vbr

+

.rmx

+

application/vnd.rn-realsystem-rmx

+

.rnx

+

application/vnd.rn-realplayer

+

.rp

+

image/vnd.rn-realpix

+

.rpm

+

audio/x-pn-realaudio-plugin

+

.rsml

+

application/vnd.rn-rsml

+

.rt

+

text/vnd.rn-realtext

+

.rtf

+

application/msword

+

.rtf

+

application/x-rtf

+

.rv

+

video/vnd.rn-realvideo

+

.sam

+

application/x-sam

+

.sat

+

application/x-sat

+

.sdp

+

application/sdp

+

.sdw

+

application/x-sdw

+

.sis

+

application/vnd.symbian.install

+

.sisx

+

application/vnd.symbian.install

+

.sit

+

application/x-stuffit

+

.slb

+

application/x-slb

+

.sld

+

application/x-sld

+

.sldx

+

application/vnd.openxmlformats-officedocument.presentationml.slide

+

.slk

+

drawing/x-slk

+

.smi

+

application/smil

+

.smil

+

application/smil

+

.smk

+

application/x-smk

+

.snd

+

audio/basic

+

.sol

+

text/plain

+

.sor

+

text/plain

+

.spc

+

application/x-pkcs7-certificates

+

.spl

+

application/futuresplash

+

.spp

+

text/xml

+

.ssm

+

application/streamingmedia

+

.sst

+

application/vnd.ms-pki.certstore

+

.stl

+

application/vnd.ms-pki.stl

+

.stm

+

text/html

+

.sty

+

application/x-sty

+

.svg

+

image/svg+xml

+

.swf

+

application/x-shockwave-flash

+

.tdf

+

application/x-tdf

+

.tg4

+

application/x-tg4

+

.tga

+

application/x-tga

+

.tif

+

image/tiff

+

.tif

+

application/x-tif

+

.tiff

+

image/tiff

+

.tld

+

text/xml

+

.top

+

drawing/x-top

+

.torrent

+

application/x-bittorrent

+

.tsd

+

text/xml

+

.txt

+

text/plain

+

.uin

+

application/x-icq

+

.uls

+

text/iuls

+

.vcf

+

text/x-vcard

+

.vda

+

application/x-vda

+

.vdx

+

application/vnd.visio

+

.vml

+

text/xml

+

.vpg

+

application/x-vpeg005

+

.vsd

+

application/vnd.visio

+

.vsd

+

application/x-vsd

+

.vss

+

application/vnd.visio

+

.vst

+

application/vnd.visio

+

.vst

+

application/x-vst

+

.vsw

+

application/vnd.visio

+

.vsx

+

application/vnd.visio

+

.vtx

+

application/vnd.visio

+

.vxml

+

text/xml

+

.wav

+

audio/wav

+

.wax

+

audio/x-ms-wax

+

.wb1

+

application/x-wb1

+

.wb2

+

application/x-wb2

+

.wb3

+

application/x-wb3

+

.wbmp

+

image/vnd.wap.wbmp

+

.wiz

+

application/msword

+

.wk3

+

application/x-wk3

+

.wk4

+

application/x-wk4

+

.wkq

+

application/x-wkq

+

.wks

+

application/x-wks

+

.wm

+

video/x-ms-wm

+

.wma

+

audio/x-ms-wma

+

.wmd

+

application/x-ms-wmd

+

.wmf

+

application/x-wmf

+

.wml

+

text/vnd.wap.wml

+

.wmv

+

video/x-ms-wmv

+

.wmx

+

video/x-ms-wmx

+

.wmz

+

application/x-ms-wmz

+

.wp6

+

application/x-wp6

+

.wpd

+

application/x-wpd

+

.wpg

+

application/x-wpg

+

.wpl

+

application/vnd.ms-wpl

+

.wq1

+

application/x-wq1

+

.wr1

+

application/x-wr1

+

.wri

+

application/x-wri

+

.wrk

+

application/x-wrk

+

.ws

+

application/x-ws

+

.ws2

+

application/x-ws

+

.wsc

+

text/scriptlet

+

.wsdl

+

text/xml

+

.wvx

+

video/x-ms-wvx

+

.xap

+

application/x-silverlight-app

+

.x_b

+

application/x-x_b

+

.xdp

+

application/vnd.adobe.xdp

+

.xdr

+

text/xml

+

.xfd

+

application/vnd.adobe.xfd

+

.xfdf

+

application/vnd.adobe.xfdf

+

.xhtml

+

text/html

+

.xls

+

application/vnd.ms-excel

+

.xls

+

application/x-xls

+

.xlsx

+

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

+

.xltx

+

application/vnd.openxmlformats-officedocument.spreadsheetml.template

+

.xlw

+

application/x-xlw

+

.xml

+

text/xml

+

.xpl

+

audio/scpls

+

.xq

+

text/xml

+

.xql

+

text/xml

+

.xquery

+

text/xml

+

.xsd

+

text/xml

+

.xsl

+

text/xml

+

.xslt

+

text/xml

+

.xwd

+

application/x-xwd

+

.x_t

+

application/x-x_t

+

.yaml

+

text/vnd.yaml

+

.yml

+

text/vnd.yml

+

.webp

+

image/webp

+

.tar

+

application/x-tar

+

.zip

+

application/zip

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2202.html b/docs/obs_3rd_party/java_sdk/obs_21_2202.html new file mode 100644 index 000000000..3e7a88000 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2202.html @@ -0,0 +1,20 @@ + + +

Change History

+
+
+ + + + + + + +

Release Date

+

What's New

+

2025-03-30

+

This is the first official release.

+
+
+
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2301.html b/docs/obs_3rd_party/java_sdk/obs_21_2301.html new file mode 100644 index 000000000..75b387fd8 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2301.html @@ -0,0 +1,13 @@ + + +

Client-Side Encryption

+
+ + diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2302.html b/docs/obs_3rd_party/java_sdk/obs_21_2302.html new file mode 100644 index 000000000..dfbe58ef6 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2302.html @@ -0,0 +1,102 @@ + + +

Overview

+

Client-side encryption is a process where data is encrypted using the selected encryption method and information on your local PC before it is transmitted to an OBS server. During this process, the encryption method used and necessary information required for decryption will be stored in object metadata. During a download, the OBS SDK decrypts the data based on the key provided and the information stored in object metadata, and then returns the decrypted data.

+
  • OBS does not store your master key in any way. Keep your master key correct and intact. If your master key is lost or mistakenly used, your data cannot be decrypted.
  • Do not modify the decryption information stored in object metadata when moving or replicating an encrypted object or modifying the object metadata. If you do so, your data cannot be decrypted.
  • For security purposes, later SDK versions will use RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING in place of RSA for encryption and, therefore, will be incompatible with earlier versions.
  • You are advised to add the SDK version information to master-key-info to avoid data encryption or decryption failures caused by changes of encryption algorithms and key length restrictions.
  • Consider both security and performance when determining the RSA key size. Later SDK versions will require the key size be larger than 3,072 bits.
  • Consider both security and performance when configuring secureRandom.
  • RSA keys in PKCS #8 format are recommended.
+
+

Encryption Process and Cipher Suites

The OBS SDK for Java offers two cipher suite generators: CTRCipherGenerator based on AES-CTR, and CtrRSACipherGenerator based on RSA and AES-CTR.

+

If CTRCipherGenerator is used to upload objects, you need to provide a data key. The SDK then randomly generates an initial value for each object and uses the data key and initial value to encrypt the object. After the encryption, the SDK uploads the encrypted object to OBS and stores its initial value in object metadata. To download this object, you need to use the same data key used for upload. The SDK automatically obtains the initial value from object metadata, uses the data key provided and initial value to decrypt the object, and returns the decrypted data. If a different data key is provided for download, the SDK returns an unavailable decrypted file.

+

If CtrRSACipherGenerator is used to upload objects, you need to provide an RSA public key. The SDK then randomly generates a data key and initial value for each object and uses them to encrypt the object. After that, the SDK uploads the encrypted object to OBS and then uses the provided RSA key to encrypt the data key. The encrypted data key and initial value are stored in the object metadata. To download this object, you need to provide the corresponding RSA private key. The SDK then automatically obtains the data key and initial value stored in the object metadata and uses the provided RSA private key to decrypt the data key. If the provided private key does not match the public key used for upload, an error will be reported. After the data key is decrypted, the SDK uses the decrypted data key and initial value to decrypt the object and returns the decrypted data.

+
+

API Changes

CryptoObsClient is inherited from ObsClient. Except the APIs listed in the following table, all other APIs of CryptoObsClient are the same as those of ObsClient.

+ +
+ + + + + + + + + + +
Table 1 CryptoObsClient

API

+

CryptoObsClient API Action

+

putObject

+

Encrypts streams or files and then upload them to OBS.

+

getObject

+

Returns the decrypted data streams.

+
+
+
+

Decryption Information in Metadata

The SDK saves the information required for decryption in the user-defined metadata of an object and does not back it up. If you modify the stored information, data cannot be decrypted. The following table describes the information required for decryption.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2

Parameter

+

Mandatory (Yes/No)

+

Description

+

encrypted-algorithm

+

Yes

+

Information about a cipher suite

+

encrypted-object-key

+

Yes when CtrRSACipherGenerator is used

+

Data key encrypted using an RSA key

+

encrypted-start

+

Yes

+

String of the Base64-encoded initial value used for encryption

+

master-key-info

+

No

+

Information about encryption keys

+

plaintext-sha256

+

No

+

SHA-256 value of the object before being encrypted (not available for streaming uploads)

+

plaintext-content-length

+

No

+

Length of the object before being encrypted (not available for streaming uploads)

+

encrypted-sha256

+

No

+

SHA-256 value of the object after being encrypted (not available for streaming uploads)

+
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_21_2303.html b/docs/obs_3rd_party/java_sdk/obs_21_2303.html new file mode 100644 index 000000000..718700a56 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_21_2303.html @@ -0,0 +1,665 @@ + + +

Client-Side Encryption APIs

+

Initializing CryptoCipher

OBS SDK for Java provides two cipher suites for you to choose from.

+

CtrRSACipherGenerator is inherited from CTRCipherGenerator but only requires you to provide an RSA public or private key to encrypt or decrypt the randomly generated data key.

+

CTRCipherGenerator requires only one data key. This key is used to encrypt all objects.

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1 CtrRSACipherGenerator parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

privateKey

+

PrivateKey

+

Yes when decrypting objects (for example, getObject)

+

Explanation:

+

RSA private key.

+

Default value:

+

None

+

publicKey

+

PublicKey

+

Yes for encryption (for example, putObject)

+

Explanation:

+

RSA public key.

+

Default value:

+

None

+

masterKeyInfo

+

String

+

No

+

Explanation:

+

Key information, which is stored in the user-defined metadata of objects to help you identify keys. You need to maintain the mappings between keys and masterKeyInfo on your own.

+

Default value:

+

None

+

secureRandom

+

SecureRandom

+

Yes

+

Explanation:

+

Secure random number generator, which is used to randomly generate cryptoKeyBytes and cryptoIvBytes.

+

Default value:

+

None

+

needSha256

+

boolean

+

No

+

Explanation:

+

Whether to verify the SHA-256 value of the encrypted data and to add SHA-256 values calculated before and after the encryption to the user-defined metadata.

+
NOTE:

To reduce memory overheads, the SDK uses streaming computing, which means that a file needs to be read and encrypted twice in a common upload and three times in a resumable upload.

+
+

Value range:

+

If need_sha256 is set to true, the SDK automatically calculates SHA-256 before and after the object is encrypted and saves the two values to the user-defined metadata of the object. In addition, the SDK adds the SHA-256 value of the encrypted object to the request header when sending a request to the server. After receiving the request, the server calculates the SHA-256 value of the object and checks the consistency between the calculated and the received values. If they are inconsistent, an error message is returned.

+

false: The SHA-256 value of the encrypted data is not verified.

+

Default value:

+

false

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2 CTRCipherGenerator parameters

Parameter

+

Type

+

Mandatory (Yes/No)

+

Description

+

masterKeyInfo

+

String

+

No

+

Explanation:

+

Key information, which is stored in the user-defined metadata of objects to help you identify cryptoKeyBytes. You need to maintain the mappings between cryptoKeyBytes and masterKeyInfo on your own.

+

Default value:

+

None

+

cryptoKeyBytes

+

byte[]

+

Yes

+

Explanation:

+

Data key used for encrypting data.

+

Restrictions:

+

The value must be 32 bytes long.

+

Default value:

+

None

+

cryptoIvBytes

+

byte[]

+

No

+

Explanation:

+

Initial value used for encrypting data.

+

Restrictions:

+
  • The value must be 16 bytes long.
  • If this parameter is specified, all objects are encrypted using the specified initial value. If this parameter is not specified, the SDK randomly generates an initial value for each object.
+

Default value:

+

None

+

secureRandom

+

SecureRandom

+

Yes

+

Explanation:

+

Secure random number generator, for use when either cryptoKeyBytes or cryptoIvBytes is missing.

+

Default value:

+

None

+

needSha256

+

boolean

+

No

+

Explanation:

+

Whether to verify the SHA-256 value of the encrypted data and to add SHA-256 values calculated before and after the encryption to the user-defined metadata.

+
NOTE:

To reduce memory overheads, the SDK uses streaming computing, which means that a file needs to be read and encrypted twice in a common upload and three times in a resumable upload.

+
+

Value range:

+

If need_sha256 is set to true, the SDK automatically calculates SHA-256 before and after the object is encrypted and saves the two values to the user-defined metadata of the object. In addition, the SDK adds the SHA-256 value of the encrypted object to the request header when sending a request to the server. After receiving the request, the server calculates the SHA-256 value of the object and checks the consistency between the calculated and the received values. If they are inconsistent, an error message is returned.

+

false: The SHA-256 value of the encrypted data is not verified.

+

Default value:

+

false

+
+
+
+

Initializing CryptoObsClient

CryptoObsClient is inherited from ObsClient. For its configuration details, see Creating and Configuring an OBS Client.

+

Method

+

CryptoObsClient(String accessKey, String secretKey, String endPoint, CTRCipherGenerator ctrCipherGenerator)

+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Table 3 Parameters for initializing CryptoObsClient

Parameter

+

Description

+

Recommended Value

+

accessKey

+

Explanation:

+

Access key ID (AK).

+

Default value:

+

An empty string, indicating an anonymous user.

+

N/A

+

secretKey

+

Explanation:

+

Secret access key (SK).

+

Default value:

+

An empty string, indicating an anonymous user.

+

N/A

+

endPoint

+

Explanation:

+

OBS server address. It consists of a protocol type, domain name, and port number, for example, https://your-endpoint:443. For security purposes, you are advised to use HTTPS.

+

Default value:

+

None

+

N/A

+

ctrCipherGenerator

+

Explanation:

+

Cipher suite used by the client.

+

Value range:

+ +

Default value:

+

None

+

N/A

+
+
+

APIs That Support Client-Side Encryption

+
+ + + + + + + + + + +
Table 4 APIs that support client-side encryption

Method

+

Description

+

putObject

+

Uploads an object.

+

getObject

+

Downloads an object.

+
+
+
+

Code Examples

CtrRSACipherGenerator:
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
import com.obs.services.ObsConfiguration;
+import com.obs.services.crypto.CTRCipherGenerator;
+import com.obs.services.crypto.CryptoObsClient;
+import com.obs.services.crypto.CtrRSACipherGenerator;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.PutObjectResult;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
+
+public class CtrRSACipherGeneratorDemo001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        CtrRSACipherGenerator ctrRSACipherGenerator = null;
+        try {
+            String examplePrivateKeyPath = "yourRSAPrivateKeyPath";
+            String examplePublicKeyPath = "yourRSAPublicKeyPath";
+            ObsConfiguration config = new ObsConfiguration();
+            PrivateKey privateKeyObj = CtrRSACipherGenerator.importPKCS8PrivateKey(examplePrivateKeyPath);
+            PublicKey publicKeyObj = CtrRSACipherGenerator.importPublicKey(examplePublicKeyPath);
+            ctrRSACipherGenerator =
+                    new CtrRSACipherGenerator(
+                            "example_master_key_info", true, config.getSecureRandom(), privateKeyObj, publicKeyObj);
+
+        } catch (IllegalArgumentException | IOException | NoSuchAlgorithmException | InvalidKeySpecException e) {
+            e.printStackTrace();
+        }
+        assert ctrRSACipherGenerator != null;
+        // Create an ObsClient instance.
+        try (CryptoObsClient cryptoObsClient = new CryptoObsClient(ak, sk, securityToken, endPoint, ctrRSACipherGenerator)) {
+            String exampleBucketName = "example-bucket";
+            String exampleObjectKey = "exampleObjectKey";
+            String examplePlainTextFilePath = "examplePlainTextFilePath";
+            String exampleDecryptedFilePath = "exampleDecryptedFilePath";
+            PutObjectResult putObjectResult =
+                    cryptoObsClient.putObject(exampleBucketName, exampleObjectKey, new File(examplePlainTextFilePath));
+            System.out.println("HTTP Code: " + putObjectResult.getStatusCode());
+            System.out.println("Etag: " + putObjectResult.getEtag());
+            // The object is successfully encrypted on the client and then uploaded.
+            System.out.println("CtrRSACipherGeneratorDemo001 putObject successfully");
+
+            GetObjectRequest getObjectRequest = new GetObjectRequest(exampleBucketName, exampleObjectKey);
+            ObsObject obsObject = cryptoObsClient.getObject(getObjectRequest);
+            InputStream input = obsObject.getObjectContent();
+            byte[] b = new byte[1024];
+            FileOutputStream fileOutputStream = new FileOutputStream(exampleDecryptedFilePath);
+            int len;
+            while ((len = input.read(b)) != -1) {
+                fileOutputStream.write(b, 0, len);
+            }
+            fileOutputStream.close();
+            input.close();
+
+            System.out.println("HTTP Code: " + obsObject.getMetadata().getStatusCode());
+            // The object is successfully decrypted on the client and then downloaded.
+            System.out.println("CtrRSACipherGeneratorDemo001 getObject successfully");
+
+            // Check whether the file remains the same before encryption and after decryption.
+            byte[] plainTextFileSha256 = CTRCipherGenerator.getFileSha256Bytes(examplePlainTextFilePath);
+            byte[] decryptedFileSha256 = CTRCipherGenerator.getFileSha256Bytes(exampleDecryptedFilePath);
+            String plainTextFileSha256Base64Encoded = CTRCipherGenerator.getBase64Info(plainTextFileSha256);
+            String decryptedFileSha256Base64Encoded = CTRCipherGenerator.getBase64Info(decryptedFileSha256);
+            System.out.println("plainTextFileSha256 base64 encoded: " + plainTextFileSha256Base64Encoded);
+            System.out.println("decryptedFileSha256 base64 encoded: " + decryptedFileSha256Base64Encoded);
+            System.out.println(
+                    "plainTextFileSha256 equals decryptedFileSha256 ? "
+                            + decryptedFileSha256Base64Encoded.equals(plainTextFileSha256Base64Encoded));
+            System.out.println("CtrRSACipherGeneratorDemo001 successfully");
+        } catch (ObsException e) {
+            System.out.println("CtrRSACipherGeneratorDemo001 failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CtrRSACipherGeneratorDemo001 putObject failed");
+            // Print other error details.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+

CTRCipherGenerator:

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
import com.obs.services.crypto.CTRCipherGenerator;
+import com.obs.services.crypto.CryptoObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.GetObjectRequest;
+import com.obs.services.model.ObsObject;
+import com.obs.services.model.PutObjectResult;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+public class CTRCipherGeneratorDemo001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+          CTRCipherGenerator ctrCipherGenerator = null;
+        try {
+            SecureRandom secureRandom = SecureRandom.getInstanceStrong();
+            // Note that in Linux, using SecureRandom.getInstanceStrong() may block the thread in case of insufficient system entropy. In this case, you are advised to either use entropy addition methods or set SecureRandom in another way.
+            byte[] exampleMasterKey = new byte[CTRCipherGenerator.CRYPTO_KEY_BYTES_LEN];
+            secureRandom.nextBytes(exampleMasterKey);
+            // Replace exampleMasterKey with the one you actually use. Make sure the key is 32 bytes and keep it properly.
+            ctrCipherGenerator =
+                    new CTRCipherGenerator("example_master_key_info", exampleMasterKey, true, secureRandom);
+        } catch (IllegalArgumentException | NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        assert ctrCipherGenerator != null;
+        // Create an ObsClient instance.
+        try (CryptoObsClient cryptoObsClient =
+                new CryptoObsClient(ak, sk, securityToken, endPoint, ctrCipherGenerator)) {
+            String exampleBucketName = "example-bucket";
+            String exampleObjectKey = "exampleObjectKey";
+            String examplePlainTextFilePath = "examplePlainTextFilePath";
+            String exampleDecryptedFilePath = "exampleDecryptedFilePath";
+            PutObjectResult putObjectResult =
+                    cryptoObsClient.putObject(exampleBucketName, exampleObjectKey, new File(examplePlainTextFilePath));
+            System.out.println("HTTP Code: " + putObjectResult.getStatusCode());
+            System.out.println("Etag: " + putObjectResult.getEtag());
+            // The object is successfully encrypted on the client and then uploaded.
+            System.out.println("CTRCipherGeneratorDemo001 putObject successfully");
+
+            GetObjectRequest getObjectRequest = new GetObjectRequest(exampleBucketName, exampleObjectKey);
+            ObsObject obsObject = cryptoObsClient.getObject(getObjectRequest);
+            InputStream input = obsObject.getObjectContent();
+            byte[] b = new byte[1024];
+            FileOutputStream fileOutputStream = new FileOutputStream(exampleDecryptedFilePath);
+            int len;
+            while ((len = input.read(b)) != -1) {
+                fileOutputStream.write(b, 0, len);
+            }
+            fileOutputStream.close();
+            input.close();
+
+            System.out.println("HTTP Code: " + obsObject.getMetadata().getStatusCode());
+            // The object is successfully decrypted on the client and then downloaded.
+            System.out.println("CTRCipherGeneratorDemo001 getObject successfully");
+            
+            // Check whether the file remains the same before encryption and after decryption.
+            byte[] plainTextFileSha256 = CTRCipherGenerator.getFileSha256Bytes(examplePlainTextFilePath);
+            byte[] decryptedFileSha256 = CTRCipherGenerator.getFileSha256Bytes(exampleDecryptedFilePath);
+            String plainTextFileSha256Base64Encoded = CTRCipherGenerator.getBase64Info(plainTextFileSha256);
+            String decryptedFileSha256Base64Encoded = CTRCipherGenerator.getBase64Info(decryptedFileSha256);
+            System.out.println("plainTextFileSha256 base64 encoded: " + plainTextFileSha256Base64Encoded);
+            System.out.println("decryptedFileSha256 base64 encoded: " + decryptedFileSha256Base64Encoded);
+            System.out.println(
+                    "plainTextFileSha256 equals decryptedFileSha256 ? "
+                            + decryptedFileSha256Base64Encoded.equals(plainTextFileSha256Base64Encoded));
+            System.out.println("CTRCipherGeneratorDemo001 successfully");
+        } catch (ObsException e) {
+            System.out.println("CTRCipherGeneratorDemo001 failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code: " + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message: " + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+        } catch (Exception e) {
+            System.out.println("CTRCipherGeneratorDemo001 putObject failed");
+            // Print other error details.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+

+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_23_1712.html b/docs/obs_3rd_party/java_sdk/obs_23_1712.html new file mode 100644 index 000000000..95eedb4f3 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_23_1712.html @@ -0,0 +1,14 @@ + + +

How Do I Get My Account ID and User ID?

+

Obtaining the Account ID and User ID

When calling APIs, you may need to specify the account ID (DomainID) and user ID (UserID) in some requests. You need to obtain them from the console in advance. To obtain them from the console, do as follows:

+
  1. Log in to the management console.
  2. Hover the mouse pointer over the username and choose My Credentials from the drop-down list.

    On the My Credentials page, view the account ID and user ID.

    +

+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_23_1713.html b/docs/obs_3rd_party/java_sdk/obs_23_1713.html new file mode 100644 index 000000000..ec3d1b7f2 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_23_1713.html @@ -0,0 +1,124 @@ + + +

How Do I Limit the Rate During Object Upload?

+

This example limits the upload rate by specifying the x-obs-traffic-limit header. The SDK transparently transmits the header for the server to verify.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload a file.
+            // localfile indicates the path of the local file to be uploaded, in which the file name must be specified.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectkey");
+            request.setFile(new File("localfile"));
+            HashMap<String, String> userHeaders = new HashMap<>();
+            // Specify x-obs-traffic-limit as the rate limit, in bit/s. 819200 (100 KB/s) is used in this example.
+            userHeaders.put("x-obs-traffic-limit","819200");
+            request.setUserHeaders(userHeaders);
+            PutObjectResult putObjectResult = obsClient.putObject(request); 
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_23_1714.html b/docs/obs_3rd_party/java_sdk/obs_23_1714.html new file mode 100644 index 000000000..84ada8deb --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_23_1714.html @@ -0,0 +1,116 @@ + + +

How Do I Limit the Rate During Object Download?

+

This example limits the download rate by specifying the x-obs-traffic-limit header. The SDK transparently transmits the header for the server to verify.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.ObsObject;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+public class GetObject001 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Download an object.
+            GetObjectRequest request = new GetObjectRequest("examplebucket", "objectname");
+            HashMap<String, String> userHeaders = new HashMap<>();        
+            // Specify x-obs-traffic-limit as the rate limit, in bit/s. 819200 (100 KB/s) is used in this example.
+            userHeaders.put("x-obs-traffic-limit","819200");        
+            request.setUserHeaders(userHeaders);      
+            ObsObject obsObject = obsClient.getObject(request);
+        } catch (ObsException e) {
+            System.out.println("getObjectContent failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("getObjectContent failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/obs_23_1715.html b/docs/obs_3rd_party/java_sdk/obs_23_1715.html new file mode 100644 index 000000000..41bee3bb9 --- /dev/null +++ b/docs/obs_3rd_party/java_sdk/obs_23_1715.html @@ -0,0 +1,124 @@ + + +

How Do I Configure the referer Header?

+

This example uploads localfile to examplebucket as objectkey and sets the referer header to https://example.com*.

+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.PutObjectRequest;
+import java.io.File;
+public class PutObject004 {
+    public static void main(String[] args) {
+        // Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
+        // Obtain an AK/SK pair on the management console.
+        String ak = System.getenv("ACCESS_KEY_ID");
+        String sk = System.getenv("SECRET_ACCESS_KEY_ID");
+        // (Optional) If you are using a temporary AK/SK pair and a security token to access OBS, you are advised not to use hard coding, which may result in information leakage.
+        // Obtain an AK/SK pair and a security token using environment variables or import them in other ways.
+        // String securityToken = System.getenv("SECURITY_TOKEN");
+        // Enter the endpoint corresponding to the region where the bucket is located.
+        String endPoint = "https://your-endpoint";
+        // Obtain an endpoint using environment variables or import it in other ways.
+        //String endPoint = System.getenv("ENDPOINT");
+        
+        // Create an ObsClient instance.
+        // Use a permanent AK/SK pair to initialize the client.
+        ObsClient obsClient = new ObsClient(ak, sk,endPoint);
+        // Use a temporary AK/SK pair and security token to initialize the client.
+        // ObsClient obsClient = new ObsClient(ak, sk, securityToken, endPoint);
+
+        try {
+            // Upload a file.
+            // localfile indicates the path of the local file to be uploaded, in which the file name must be specified.
+            PutObjectRequest request = new PutObjectRequest();
+            request.setBucketName("examplebucket");
+            request.setObjectKey("objectkey");
+            request.setFile(new File("localfile"));
+            HashMap<String, String> userHeaders = new HashMap<>();
+            // Specify the referer header when uploading an object.
+            userHeaders.put("referer","https://example.com*");
+            request.setUserHeaders(userHeaders);
+            PutObjectResult putObjectResult = obsClient.putObject(request); 
+            System.out.println("putObject successfully");
+        } catch (ObsException e) {
+            System.out.println("putObject failed");
+            // Request failed. Print the HTTP status code.
+            System.out.println("HTTP Code:" + e.getResponseCode());
+            // Request failed. Print the server-side error code.
+            System.out.println("Error Code:" + e.getErrorCode());
+            // Request failed. Print the error details.
+            System.out.println("Error Message:" + e.getErrorMessage());
+            // Request failed. Print the request ID.
+            System.out.println("Request ID:" + e.getErrorRequestId());
+            System.out.println("Host ID:" + e.getErrorHostId());
+            e.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("putObject failed");
+            // Print other error information.
+            e.printStackTrace();
+        }
+    }
+}
+
+
+
+
+ +
+ diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/caution_3.0-en-us.png b/docs/obs_3rd_party/java_sdk/public_sys-resources/caution_3.0-en-us.png new file mode 100644 index 0000000000000000000000000000000000000000..60f60762138fe7d98fa081415cf26a4943897779 GIT binary patch literal 2752 zcmV;x3P1IUP)pPa!Eu%RCwC$n`u~-F-BFk{0Y@>jH&Wt02T)4n7aXBssVicB` zOX`JaF2{q_2~&#?rkP8$id|Xfs23G(+0lTGT0tnFxgZFMIx;xG$R>Lr2ng2sFhB=q zSd{Td_5QEx{V+WDJooe7@Bg{)|8u`XpV~`~ZvvYTAfN{@5<(zAAd&!qNCE^R2@oI< zNq|5k0e^NPrRGdyW8`F%MH7XH|3P8=s2${2dg49z003YAM?%tm1!4=85P2aZJs3WS zG6CT8kCv0C(eT;v!9vu9jP&3oZEw^8HmnQ6+clMCL4mv(zK?)Ob8&M#`$%sr@v0v& z@zoUHs-n619H>uFER~Aj==ntk06q~XtAWrX`-(7l=)GLjQP?!@q z{@ZTZw0`amLgo~4vvd&0Pxryp)QHy>ob2%4P9)V*SX4zr!(BuoQ>IK9!d&k>z1cqI z{8L;})njUE#LIJj>h%6Q^ZVF{wB;i;Qi+5h9}NJn%x@raKm6;fW+Fl#T`67idLh|4 zu~b$4-1hhHTVfMtV@>p)0G=3ns@?Zq+;oGKv z*YE#+n>`1!`TpdYF4yhs&w)&meoVo}#+v$ur`WVKNyq<%YnFsZMC$eXSc!Bf$)AMeNOrxm z98up?0IbZ4d1uoLyuSG}0{xcY?H+G%68SDpqp0{6ZmtR(?ChBNKk$ZxK&chd%Fub9B!C3$z*oSdfKP$^R+Au*=jW--Q5@}8T8wOFz(A> z+jPJi0CSN!@M}8~J+m~H+qJd0$mL8L?}^W38D?fiTvJtZ_QG{CGOx1j!^2co2eNIY zE_th}e&*28WCEs4)4Ngh`F*TJs&5jrEg}J*$>Ry|NTs@Q5S4XS*jiLGYupV!l}OmJ zCkyWg!}|T(8zmGK-@ggmTpXX4Lzd^H6d8Ibpk8+o_km$bMW>TS}&FY)P96F+{d%+84 z0FbR#^Wj0eUL$0WrHtk7-A3#N4!~oiv))WDwoq|!rza!b-MC#_%g6i5bZq+f?}v+A z&dvOM*6oz`?o(Suoq{*R_pvM}5O;^mT)Ww?Z7fftAwAED0FP9BCXZ)ZL<03qVuSdN zP8xtRONCq}V{LHL13e@F7rC5Q7nL%1)>HuEPG%TvZ9T=8(JF40lp-DCMCkm>9oo4$ zp2gbI0)X_(**fDB#*QLr-bCyM4&cnWE2QR3>%BzUvd0>L#Q|n|$1Tk60kC$33wat1 zyP`b|;`hpR?G6;%TDEA7?qPdG5~XG3DCEwFEmXV^*atUP1r?Q*Z6tf#C@HG~z|7R7 z%W^bSHmKdEz8|Y+XCNKoj5;@$;5Eqx+bjkplCo$bd!u65ur3Iht+xK#S>J1CGr+PQ z0C$JWZS8>kO3xnquB&Tk(E(-;v|eN5zDOk!LKaKgc6D>}Jxa^U*&dP9D~M#(l4Wdd zEW5NF>oE`jQ&SV}G+O8_@4Ge+!`aD+oB8?teVaq?BU0GA1xO_l=1nQrAx&+WdOB8S#d?X;+5%{W zL%$q0tP5gqR7{WS^|&#ETLM_$tqfODr{F@Wvh7$L9&xbkIv%IZL`G<~%z?=et2Z8l(~lTRu|vXblrbH{CQq;M*jC6P7 zAFJjO7P_e26);09x-VYJYSS8{M>uNB=$!_=`UBu*VJQICR{ab{qy@7TIM~}!cc+es zuSRv+yK8E024LzW_fF?DH>qIv7JK9}8Okgb+deq(_=yx1KZZPwhLE7)i2By(j4ulc zZ0X+G=!}W_*0i+)j$M5C6#K-`Q^PI#NC$_uZf2|)Q-QCDmtJxjn1b~m%uQ)q7k*!v<@zee~^S^yy8n;SIv9h!z@F~L` zuV;E)#MIP`TP3BWq~-E)te=ie;#EKP>`x<4qruHp!K;f(yPS8hZ8~d0reR}ajZ`A( z(HeW)kgTXvuy(`eEDH)`tWfsw@ySLcm z71)pX#Is~7?MOOfjY2*gfad0Vq-SPfE=p#UyBs4UBW!G}*%&$+h}RorbCI@}bUZGD z(D`DX7<2A;EnO+wSMkI5S3ZiysJKOPz zXHjNr`1+U~!-i@z2TQevhO_F+9anqo4qDp6*s z{^#^#iMhy}=wm-XjcU;ayd~S zjKa+^{((2(%#||Kxw$%iyNf&$A}5<97d+PwF{vJcqF5t}K17 zWA47SPe$ba7&NE7d;EGLztWTQN_%qi?{fFvpbejgc;mTn%wk=QtX`o_PVsJpPg-Jv~RCwC$oO@7HS02Ydnp$REOA{(Mow8*Mm>A3h9MeO=6 zYU>mmT}9emv9DQm*RJeXc5T5Q!v0 zB$5b`NFqdtL=w?OklwC|&JB*_kR*g*P1STeQY~6uB+{*;B2i1mw!HxCh>m7?uX_kB zZW668hPGS7cBvYGjjLu-T2{ta(MHkoqDQ**khXqXE?M&}B*qkwZb{|!wVV0PLl1U( zh|@k2Pt@e8KI2W7%cc| zO7%;oh!GEaKI?~$MKHY5t{0Ps=^60OI`;KR@k?HRh+XkChOueL!}QpzFXL=(zz|LUxf|B{Fmxd{EXn6tyV1mZmG!*PMf2b20p#%- z`o8%ZVfQ~su(20?SHHrs3D0@S-1|flxSZIlFT0HsqCq!dAXirJ4@lTnmkYTz0`t-t zoL%_-P1mIvW2W1<$B}7tG*?~Z^s+@a=y&VTO-%?Gh7Jy#@{?>}D?H+5hs1sBQ0R>W z$rPxPB0JS9by>2#BO!*;vNGmn#B$c!n|>2>7?JiN4?lg9=9Ul^WTvn;zkmZNJ#I@f zXfLYayW|WUHCNr9F<}t$c#W4#+=3U8s&%wF9keEQnyx}+}N<*(D-{;R$ zaL&lM{`n*i9mMK`CvfP6+g4qiUbYCAy$P8{NBGDGJ>#mRNP+|zE_)NFmo4(hwYIv@ zj4}Jw)#_@YXz^U^wkl+5Ed$yU@(x$pVxcJ-ZmXBjPZHcyBPNTQ@jT3znFTMzB|S?h0gxfpz6m)AA4I1f{{Z$&2y zk3ciVjBaWI{dcTHs?p)HH*sm#raQmUz>fucJ<0Wt1$&7Yo{Gv8hdf^6w-o?Tw&YWcsTM+dBoLi8 zm#bgrQM3K5ud%~av^tvIiFi|^-&R4OlHQ{uGz@8In6F1rD1F94&As{c8*2bi=#8{A z)KIlQhtnC$?tCJxvO0({nRs+qm1oR!Z=IKnF2v^f{N$t{)~t1Vv2?ngNK$nuGEKO< zzf@ihKvc#!1ci#0h8lzrHSz1+9!LmL<7})$rq&Yk)GWTA^F~0u-~E0TNjvu-Q)}t} z)&}+s8s@*>B2&1%Q%tPac=st8NJG2{;%siGF;7#NJH;& zhtmrs6i)v0ou4BeO^#u2egO+IQwUR3_$5wT3!n{#&@*Jsx3K<;Tq+W^T~4H!KR$~@ zu5|Zlat{Mw&iD(0QiW8dAv|#;hS6ylMyC;;I1(Y)o!@mEZ@FnQU-ZJ$IBKhr$d&Y3 z@~n?c&GxedN!C@{=B92P%iuKA4P5P zF?T5M7UQl=?_?r5^a9HdpCWnaAVwy9ACNdxCO+iz-A9L25o0p3%IfG+5=G4$jjDT3 z_rX_P#9mZ`W{jEERu|5u25kR1=sC=`>*|qQT57FGWQv;}!j;wgsVgZ&P^ySbnS#<_ z@{wsQcZWQgM(3rkuisR2@ddhKm zm>y`QU}}cvFx#%9zncRR0f}5m+=3T>`k`rb(CYH78vp)0Ee*BEwGqTVll7BY1|4qD zR@y0eaw?7*EAlWsiJLyTGjpW6UP@ltw4HQIDv2=#er2YNQnNeHL|TgfF7e2O?@1my zh~&SD2{!g(;QB4N?2Xi&J%utn0;xtv zkRbctK7@An=2gu(9Ra)bZS!9G@?)aLPe-neAnxr2otkuaibwkB-UtAuk5dGci8mbQ zpHD?%2tDKXzEY@Rj-@xHWo6{`Gk44bDS}ZNOehT|CG6gP2Ggpt~a%lW$PyZ(R zi8N$tEzX8o&aMocNSD04oR)@K6nZ1(%xk%iRHX^nOsp#j+)(^s?wgdX$fl*dQ#vN{kQBLN_&` z(}>jJm$ns&TBh$jOxAo08KVLl?;k50S@-!F7S4`i=H$SR@bCXNvu5pPHYX!BHAMhH=PbZLgf2GrXYPBlYfJrz}; z)`4zn0@|b`lo3(5nj87CARk+Pp-;mw(B7`!W7{6u*6MHG>-993S9MlnGP}b>T0X$Q z*4=p=+dA4SslE}Gg;&WhtYpG)6U!Ea29!H%?ahd^54+^o0V28#9s2{xQ^UKnb$1>s zUY^}9i2&9v4QJu(xOPbdVAh?wt?d92zi^J^&vgoySb1+qmmi0B}` Z`Y-il7nw201!5QImN;7^FeRDuvlieQm$nqSgH2#ST^0cx)=Dn zcnY!FJo_HPt-fVW+YdiB+UT#;6V;vF(d}+cR@IeV(d8~pF{?8>qtl(5 z-l&f3hz@sXMqTY}N84?I)T&mtqU9C|*g%8DFx{Fx6Im5iuF|X}%dCt_S87;LjI4+X zS7=Dl>numvWx_9&xPzYqFMxz!h@dKJnV+WiNj6zrg25Bat1rHX34YcM&(@mM25EsKp^s$!A zn#VD|u6s{$op5YkSDD^r^tisfo6%**9APOOq(ypevUm*eg627JCCoz;t2Wm=9wHzA zIZpn)d?D?0K6~e%(5n+Y{``IW_383vZ~ype`|Z!iyVvi|9^OBm{E(}2>Xh(M9J1dY2CIYT07X)PL*D{uoU3SWSe zM5)Z@cZj(9E!*Rn@%yj8UtL_@?zGcisVAyCyQACPnyjiTyQ0fonqpRGc1EW=HN8j060m^=i($GodnU3fs$8X6OO{y~m9EsVpcq*Z6|T^b zqSslDvde-aqopiG$tAYJ8Zb!15?a()3^veUF{}|ZIT4x8)aYX^Swx02G;(1<(UEpq zsD~82sYp46Jp6zr)7XK2NT3kbfI%9Tw8DeMU;_=7#;04Wd;7XW>CRXi!yzvnE_|I|r wZ*w5M>1_7SKcT}DJ@4vn|M>OS_UPly>%-H_{r>p;)5Xs}-+pgDf7s~DJ6{D>Q~&?~ literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowdn.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowdn.gif new file mode 100644 index 0000000000000000000000000000000000000000..379428032932289326e52c2772bd90ba3d88b906 GIT binary patch literal 1887 zcmZ?wbhEHbCgqow z*eU^C3h_d20o>TUVm+{T^pf*)^(zt!^bPe4Kwg3=^!3HBG&dKny0|1L72#g21{a4^ z7NqJ2r55Lx7A2Jm>Ih`8X1|p zSh~8p7&*iAy5uL9=BDPA!1Sgd^t#~G3rY&P1wfl!Qj0RnQd8WD@^clyUbf1_?G{Iz z=0WwQ;C71>PQCg-$LND17Ac}(Lcr7mV#1RxkONQnsd>QEUIa|mjQ{`r{qy_R&mZ5v zef{$J)5j0*-@SeF`qj%9&!0Vg^7zri2lwyYy>t84%^TORUA=Po(!~qs&z(JU`qar2 z$B!L7a`@1}1N-;w-Lrew&K=vgZQZhY)5ZeMTG_VdAT{+S(zE> zX{jm6Nr?&Zaj`McQIQehVWA3>*p!%p5Wn0u7E$th{n6D>ft^YU5&dnB%c=(a~-RV>2EO25SIA CZ-yWM literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowrt.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-arrowrt.gif new file mode 100644 index 0000000000000000000000000000000000000000..6aaaa11c23e919c4798d7dcd2b1ae98dd35dd316 GIT binary patch literal 1890 zcmZ?wbhEHb7yetOgf{ zR2HP_2c;J0mlh?b0+lO+tSYc_E=o--$uA1Y&(DE{Vn9ZINq%ugeu08>u$h8JcxGNo zetEGbSiP^Wm1kaYNn&1ds;7&s63_&_%*+%k11Cod14Ab>6ALqQLqk^=3j-5FHzP|& zBUd9gQwvj9m|mCsATTyHM;rzL?XHK6w zdE)r7qel)OI(T6JzP)>P@7lRz`?jrHHgDRvVg0(bYgVsXxnlXUrArnsTDV~Tyt#8` z&zd=7`n0K2CQq6;p}()Ur@O1OqrI)QrMaoGp}wxRrn;)KqP(oMq`0WCAU`iRCp#-M zBRwrOB{?ZEAwDiPCORrIB0MZKBseHAz~9f;$J@)(!`;o*#o5Wx!QRf+#@fo#!raW% z#MsEtKwnQ+M_Wr%LtRZ(MOjHvL0(Q)Mp{ZzLR?H#L|8~rfS-?-hntI&gPo0)g_((w zfkE*n3y@@B&;b#k`jUY|nSq%>!ec`MLnAA%oR7zc2TpB#@>)|YCO&lN;uMU!b7Eqm H1A{dHTIz>f literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-caution.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..079c79b263f4b48089f3b3256154c73e7699593f GIT binary patch literal 1086 zcmW+#YfRQ<6hA3LZMyP?V}KhnEtF{Q4vGxS52AozEVM85nq$#%tv8gRF!3GhgM?_) zd5Luv3SKrXFTGCpn$y>EMGZQ&sWI^~+e%qWysRPK%BSD+f4-fabAGq;|Cf|4nO{(o zMH%#n$oXf^sdM5SJ4e1UbEeM389O82RCB6M#VI=_KP%=$orn{5LVlIau{svV?3jS$ z$Q-F7am0>L02|Q2!ZN1G^Z2J`V#a3VX;G<~iYc3tSAnLeiI}hnc~O{UH5OwwCTPT} zks65+8-W$70S3`f30dfY7}$UY7M95y@-?2QvMPChphYF3!YbtLLIs*E%B)Oq4^fy^ z5+zoGJ>&tI*hU=i4-s$()c}KNsKh9AfEd_-1{V3`d>b_$i;xcz{y>Y0S(uP3>_P>a zLM((Fku(B;E{r2+xJ8u612VCVIG_oJ;Sj0;2GQ7rEa(6+umMf}M1C4=)Odu8AxQWG zEh;Aearj(=d;4Z^LLYN*6+asU?Nbl3^Q%D|{s@6Xj}(aZHwkoj-~bw*1FnSd;0aX! zUW<-TPD&b;6s;@zw7K~4mF9cDuK&BQ;b_N-Cj%R=CnEjde9%~1kk}vYY^@mTTNm%F z?mbrf*~d#iX;?ITDf(MHQdK;&p(ek&e9qe?*&A0E)mG(1s`J*pn^#ttId4vCXjV$j zj464u)2F9Q$V#0!dHk4(FDB#D&wP^f0*q1)G?4!%Xe>;ROD~Oee-}xfJUd+aa_0AK zFP$vgR2te>+%}b$hVw&Ni`yT>F5LNRM@_utk68Piwi5??BLBpCcb8mx|3c*1x!xZJ zKU!7(#h8s(^x)5*w=Z0K{=a9#qeoHU|0&%MiU0rr literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-danger.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..079c79b263f4b48089f3b3256154c73e7699593f GIT binary patch literal 1086 zcmW+#YfRQ<6hA3LZMyP?V}KhnEtF{Q4vGxS52AozEVM85nq$#%tv8gRF!3GhgM?_) zd5Luv3SKrXFTGCpn$y>EMGZQ&sWI^~+e%qWysRPK%BSD+f4-fabAGq;|Cf|4nO{(o zMH%#n$oXf^sdM5SJ4e1UbEeM389O82RCB6M#VI=_KP%=$orn{5LVlIau{svV?3jS$ z$Q-F7am0>L02|Q2!ZN1G^Z2J`V#a3VX;G<~iYc3tSAnLeiI}hnc~O{UH5OwwCTPT} zks65+8-W$70S3`f30dfY7}$UY7M95y@-?2QvMPChphYF3!YbtLLIs*E%B)Oq4^fy^ z5+zoGJ>&tI*hU=i4-s$()c}KNsKh9AfEd_-1{V3`d>b_$i;xcz{y>Y0S(uP3>_P>a zLM((Fku(B;E{r2+xJ8u612VCVIG_oJ;Sj0;2GQ7rEa(6+umMf}M1C4=)Odu8AxQWG zEh;Aearj(=d;4Z^LLYN*6+asU?Nbl3^Q%D|{s@6Xj}(aZHwkoj-~bw*1FnSd;0aX! zUW<-TPD&b;6s;@zw7K~4mF9cDuK&BQ;b_N-Cj%R=CnEjde9%~1kk}vYY^@mTTNm%F z?mbrf*~d#iX;?ITDf(MHQdK;&p(ek&e9qe?*&A0E)mG(1s`J*pn^#ttId4vCXjV$j zj464u)2F9Q$V#0!dHk4(FDB#D&wP^f0*q1)G?4!%Xe>;ROD~Oee-}xfJUd+aa_0AK zFP$vgR2te>+%}b$hVw&Ni`yT>F5LNRM@_utk68Piwi5??BLBpCcb8mx|3c*1x!xZJ zKU!7(#h8s(^x)5*w=Z0K{=a9#qeoHU|0&%MiU0rr literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-huawei.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-huawei.gif new file mode 100644 index 0000000000000000000000000000000000000000..a31d60f895af919d33855217ca02daf4093136d7 GIT binary patch literal 2767 zcmV;=3NZCYNk%w1VaEV40Oo%H*MEWRpQG)+!RUX6`tR@RDKg4%aM+KK_}}3B+S#H2 z0rt<*_Nl4!k%7|y4fwgY^uNNg00pZ61NzIz@q2NyEiLIHE%S?g^NEbfKt%9!YU?yQ z^qh&+U}WbD8{q&E?Mq9<013DN2H5})@N8$u01CkX3Fs9f^{bWHKuGLFOZ1kS)=*aD z01@p=RQ9r(>pemK^YiUeQPU6`>94W!hk53YleQ2Q>_SB7aCr2fj@; z@a|n&?qX^0W?<$J9`9pa@`8Bj9VzWnT-qQk!yqQl01W6ECF?mp=LHtlFgo|Iv-PHs z+HiFBprpVM7yReuz5od5zrUyu5$;)5@{gDATVup9HOgRO=U{2(0u;*t3-Hg-^OuGE z;N9vkH}7a--=Co1Fg#jPP{_r^k&B8kCM0%mZLFxL@$v9KH8SJk;?~sDy0^BTnwV%{ zUQ9zlgnfM9U}wHiP~xwz{`dCrZ*%7e7{X9d^{Afom69VE761SLA^8LW004ggEC2ui z0LK6@000O7fPaF6goTEOh>41ejE#|lU+C8$A-c{-jb1$W_sAqMbtN`+RZ#DGFR(dnrcRE3N%f+!F;*y7(oOv#1FPiAwy#YP$z^Q7U<_8BLs** zMSr>_(L`oBgxA?;z>x3<218xJ;14v)$l4!yG&Wrk_I1$$0*;vB$B=#`at4uppizkb zkVG1Zq>_oSkp_`a7SaZiZXiMjk!m2q29j+I!X%PpB5B5wO%5V}2qJRl1%NsHfxr&G z=|x^!dAKu_41Dql0y7LOA)N(0dcZ^rABfh-m_;ITB$a5UdB~$fR(S{-NTzYfmPE#Z z$dyBCddM0`(jjJQ3^=Hu0tmpW@WUTds1O^W zCv4aPqTVsWsFRSgiX^m^Dgr8zYZ&qdl5-rgEs}5?A_tOhoSJHxtD4)WAg_+-CV)r$ z0l^3=PP3O0e*huI221P;!@n>Lqi=>hZs_9&J75vyw2nR*>5$YWnFy(5hH1$EwSHt- z2&Y^c@+FZL3&QBRsy<8z0uiv;-+usJMIdJZ34w1G1pu?}1~|L$M-&7rk*ppEBV3oW z3{UE?w2~S^sl>(pGc6ETQUgwH}48uSiAJo0SA(QX~FrGzYvq#TC0!EGVmk{K=`YG64w z*^4Iq2N`U_YT26(@Ww;iA6V3a3V*n8!U;+!QN-&o;K;WJKrdVR4kI*6wC0H)Z8+gt z8&Y|wjA~4X(?lBohtwStGUbrnULHxSg=BE{y8s3-FXI^_2KJ7l* zPUi?^WVSHxgDj2s;6@ith~r!?-DM$hAerqT7$efv{s0FgQSEnvBN74j@P$DTKnvHC zONlTuy0+nk2Y*mO7rMX%Cg?#AOZY{0)h5f{2_S7&W;+3~xxv`varUz{DmpF%e^`f&wJ41t9(5fhwzv1mBc| z0U*EuBM2j%FvtTFnh*k5Fk|UZh`TZf2my8Qf){uKMUtgzel#qE{5o z`T+owlz=pEZ~#HrKnm`Pm2OzzgBhrem4EOJodD;_ahfxf-U+}Ak|4_v=x&*|EE67c z`G;K+;#whFp8pE*u^;}yhknQwAj5S;KNQlDsB)$xqbbb@AmI*w_<|O)xy2+vAOLDp z8yCVE${l#|oS_`S5dZ^$BP4;HUf`rVX&Fy4%@bn4W7;49dBA^~$q>dQOL?8kgXdnQvsYOnDfj24t0FVQ&GJsH);SXF0X(+eq z0|aFCq_QkQ2uwgnL@)|$U)!lnaS7A<-BO9Aav~Zq1~shtZ;*=2X&Qw1zoAY~flO_x zQ=i%a0w5p*o16;-5U|cJ{sE(En`{^}sx}@hzy~=vDN0qkRui}|sdcU4U8UAnL&&wT ze-NTA73oVe_41G0LefE{2Z>hMA+geI=u@QtfIkQT2`1nUZwBxt8^}v-apD4J9dHDm z*r2j$RqI-*fP_WBP>(V+WFp;)q}Cd-rO7KqPBT@AJ}!>D^n`Dbmde!NE;eOIpur!e zT2+HIfiCh&!V$`4~D_J+6+9nP?X4+~QQR3Nd6O>yUni+~O!R{(#Yf%|x3 zV=w6V57*_SoPYe_5lO*{ETyMCXS!kI{qmTJC@5?}tYs@Z`Gp%cnIOCjX8WdC#YjMN znOSg%0i?hn3uwZe>0DG@D8{!L9NVviU!0?6(AlZm;xWpa)Zb-c0Yf<`I615cvC$3@R|NPo+jf8PRu)%BB zhMd<%u5!4#ylXATHvtr$a54bk<~ZL%26n#lMX-S98Gr)LaZUq?L;OQXHv|E!0Ok|h zR|}ywHv~IJbrC%JsW+&2(zpJHJ2XAlm3#yMI(PL)OS76>Px~OC`E{mNAnK0zLI%qI z)ZlJG?RXaiuD@;tv`>NzH;90J?Vk56!rvj>leB^Xjy?$j0N@7pwE`ImPx(Jo;pSvu Vyd?-=a{xfJ@}LjB=qC{f06U7uGEOJ7jGVWt0R$WZ8s=je-u*DOe&kq9}!i z4KyN^y7WUtlMt&*F%bljtRbDEJamX6>@vOi{twMwE+=kqtJr%yLc-a1j}Z>-)`f9GBO%WDhy=L0>5=eLzUZCI?G``P_| zXl3c^-NL}=_M!Zh=FG7pU)shB58htr9~}O0uVbq2_rt-Fxv_(zmmdB7)lfOReyZ>D zrqum6#Z#+~moGM-oS4Ziby(A(@4L&ZrWcR4wV&_mTide#$G4kXKF-|cGp}2pJe$2t GE&l)<3Z_>8 literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-notice.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..409070650a49518feb1624c624d814c3bfa63d2e GIT binary patch literal 962 zcmb7D&r8&C5S<{wSd_qn6)U)w5LOaRh!N}_*49lD)S!dZp@M<3gPIX|@UR9-fz+X3 zAaT9)OY{xZtO-;RC85Vab;JEUNIMS5f^r$7-e%-XK`j{0+N$CsgpRd6B1wp z8dw-cH^rU^H4`&7qgabf)l^K`l!66{q9$U(CKRO5%W5pfY)s&YQ6n`HBR0ZTum%`N zgC%I8hQ+`JG_WvCAt-W$sIn@BKCDG1qQWW^a=`*c7G+i@s0S(ZDv1&+K_2`7O-#cM z=m!ZX1Z#kSG+3e)Jg^wpfCd(Yb5TZ)U=a!DwsG z)Z`|1ejMK4ap%CHj;%+>T6=D++5I=uBbQ$fZ48cf{hV1}9&Njl-I}i7e0#6Hdug@s zsr-57_=gLr&9Ros$k}}M>tJ77=hEJ}iPaZ%8|P+gUbS|Oj}5I{|5nZZc)C1$e*Rj` d`09hYXJ4M@PhCx)dHK8WZo1*|*q+^V@*ncduk8Q; literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-tip.gif b/docs/obs_3rd_party/java_sdk/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..c47bae05c9fd17c02a851d96cfac67bf194498d8 GIT binary patch literal 879 zcmchWKWmj?48@OdDOZPr)a61!OE4yGD)salg#|^Ix$qIEF#uk)V>D{95e^!2r`i+9t# zTMu5YtUcd+@#gp0tDE;9ug>oLIzL$6dOx4-t#2PKExu1KulwoYeD?Os#mVO%AMWih HO|EMGZQ&sWI^~+e%qWysRPK%BSD+f4-fabAGq;|Cf|4nO{(o zMH%#n$oXf^sdM5SJ4e1UbEeM389O82RCB6M#VI=_KP%=$orn{5LVlIau{svV?3jS$ z$Q-F7am0>L02|Q2!ZN1G^Z2J`V#a3VX;G<~iYc3tSAnLeiI}hnc~O{UH5OwwCTPT} zks65+8-W$70S3`f30dfY7}$UY7M95y@-?2QvMPChphYF3!YbtLLIs*E%B)Oq4^fy^ z5+zoGJ>&tI*hU=i4-s$()c}KNsKh9AfEd_-1{V3`d>b_$i;xcz{y>Y0S(uP3>_P>a zLM((Fku(B;E{r2+xJ8u612VCVIG_oJ;Sj0;2GQ7rEa(6+umMf}M1C4=)Odu8AxQWG zEh;Aearj(=d;4Z^LLYN*6+asU?Nbl3^Q%D|{s@6Xj}(aZHwkoj-~bw*1FnSd;0aX! zUW<-TPD&b;6s;@zw7K~4mF9cDuK&BQ;b_N-Cj%R=CnEjde9%~1kk}vYY^@mTTNm%F z?mbrf*~d#iX;?ITDf(MHQdK;&p(ek&e9qe?*&A0E)mG(1s`J*pn^#ttId4vCXjV$j zj464u)2F9Q$V#0!dHk4(FDB#D&wP^f0*q1)G?4!%Xe>;ROD~Oee-}xfJUd+aa_0AK zFP$vgR2te>+%}b$hVw&Ni`yT>F5LNRM@_utk68Piwi5??BLBpCcb8mx|3c*1x!xZJ zKU!7(#h8s(^x)5*w=Z0K{=a9#qeoHU|0&%MiU0rr literal 0 HcmV?d00001 diff --git a/docs/obs_3rd_party/java_sdk/public_sys-resources/note_3.0-en-us.png b/docs/obs_3rd_party/java_sdk/public_sys-resources/note_3.0-en-us.png new file mode 100644 index 0000000000000000000000000000000000000000..57a0e1f53377b28fd80ceb393b035f8d9b8b392a GIT binary patch literal 1080 zcmV-81jqY{P)pI>PbXFRA}Dqnq7z+RTRg6r`*v5D@IBmL~4s5$SN3-f`YICkrqS^ z3O*?4J{4psT?>Nv;P$DA4|YKmeJd1v=!+{-P(e)MT23E4 zfpM5g?!;YNyXOywggfWv-aG#}pA%7499KRz`7Lmw98Q!I<#3`LPLvbnaH1TQ5UMEG zlVk_b1{y%CK&5Na8Kh~iV1CQyHSIUD=$Ui|Y1(mW{t2nlnW!hpqTT3)%#9tQ2@Hwc z4!jG@4brq%Pm%+`OlEvYXy4{GY5awd{We?gCpulWuT{Z9`oN)jk~9ZtI#ba@Tm#IC$eXI#i?GB7 z@C|Siuxi7{ffK+jzyrW_z5t&id2Xi{7fGOZ7RUNhF z=`q(YYu4B2zr}fA1-My6UW~A&C(H`Z0J{sqLLYb>ST?)$UTJH~j4 z)U5D`kx~@HyTBjADBwh`9UcOHGnaO3gx+o=^sFTdqcDs&7cD!S1Y1R9DJQENmMBXi zUX68u7SqPL=oS0?tDydiCJNY=lMCxo@cxg;Iw&H0tZv&cB5#jSkGc8v45{4-xAi@+ zH#c^6Llb3aTk2cp0#8`%*2*ZSb3DivIwje71|rV*JnwHI2e{V0 z?L}VtT_k|}D>qFKHz^_)cUMxtxkDBWXzz2D1oirfKkqs5Z>m~O`i+$JJR1>-NN>fsG-Q5hHbmeou}1??2@ zp;^{uvz{qy3k557pH|h^|K(Paf~;?wS^K(J)S`9Ki+p;|vZBS3*BostG+QG&8PgN& z=@C2h$ubuxBJTs&=XH#%UFPZrh=oAMNN{DPG_uReuDWcPESRPGOKD;{Otwcu3X@*QY`k0+@}-e yxT4{IZgHXpLI!Q!9RCwC$n{8}UWfaGMW8J;IUE8&LY1fUhGLTVa3!QBW+ZA*L=y*M3rfr5il?z?dJZieJ#47>M$@*mD4$1ecadv1qsU1#wR$;qu4Bmh4yS`Hi)ReG=4*#e zajgEV5YlLPaKTMvrW)|6L6Y@JtlU|tX}9u@d<^;|8a!TJ`kRn8mKIZX-z)%<^+`jn z738I}>P{CwooQ#@mc8ItdHsQ6rsk%O$iLY)*x7Zcj%}lwEK@`-=;otzSyX+&p9{kzQYbgSF@Q=2Qy+?#VW0=Vy|cYT&lQ@%;A2YQ{hH z9%ov+34{hBa~SnWOw39F;7p5`9$z4G?cJ)An*I*rb~&khdI=d8h1SkK)If-j5C2TB z8p4%r<<^31tR|Tw4Xs1QHMjMk20}yD8f4p%dXd_$me9Z-SWPlj8%nUOe;>LpUUAI& z1+$nxI~Q3>q`9q!{1-nPlEMa4o@e_SGSdvCrzn))J%_ut?ipfIn4e4CD=Pq4zT@D? zqk$|@wV{L*qfBG7mtFghv-Lntl$pcnz~kwNI)BUSUuvgmQEXp5=UThz?DmmjlsW$V z@)3#dyh6UbBYa%QD%n4gom-Glu20@0My{Xs3VRpaU9=0QxbJP-J)Pz^`?kOW30Tn z@ufYqb@gL4$<)8N0%S?kG%v#(IqvH7UvcW1v+a@N8!}9Baks0-uUUYP1beE1+)Q)S zUobczB2ql)J>S90pM1~e2X4k70q-59;@Rj(Ixc6Ok_Z$V@dbE+GNTrV;HlFQ=lRMeN%CX^J*|inqrfX$fdWuECU& zYE~#M%8xCgqI||*N`--7Xw)BgEZ#bB0-qYhW>q--LhLmBU*r0E*5+4PP+l2n2}rtV z_qXh+#jl32SrvAyo2R)OD=o_BoyYIMW>x6y_Tety7r)3^eF8`TK$3KP{`eA2F}YpN zxa|~0YP$+*PB&3e-M~W&UFbFHknL5q%yVT?GB=Ox3?p^VEh7*N@$03nevU0%RA*Qe zy8Bd~e78Ejsl=~x+vYF$e)B!#In3BC3Kw>)rNi4F>6}lnndnzTghB(1f9&nZP({}9 z<_Y#X?@5R5*rUdbm zZ9zPQB)-@t_#f`t1VTsxAtZr72uUD>BoIOp2q6gsLP&yt3mvdY+y=oIIs7M?<}pwN SX0_=60000pR4oO5oRCwC$oPSW0cb>;zfj~mSuLKN~5E4Ot2?$cVg1bfW*MgmP zwXW?r{^)GC>z&@*cI;fk*-bA_)*65J|u{1o1b~sY9&bgB!&FtPHC|>aqwkEf8t)sIV8a zy`l<$fv1-750WZjrUfER4&AbBw(qRs>9xxN*j}-pMOzA)VQ&y-TOiWJv9nVR=-IGB zL`2wi-rWtmJCwYrnwtLq8d^@54N{_E#qc2?d98FYUt9|#UM6CV$k!5{lNa$(kHW9K zOnWgQF}`S;)25`yKPRE0?;CL9SWtgolNa zrBRX}cY`9==aUXcrj$ru%8RMoU&9MOUrS=-S8j{+s~_?FOYc$kFAFFdtPOe${ncT1 z{rLzf8V%)-DtvDE-wqmRZ8xCPYAJtA<5`q3{Ob`bjZO9Fv|84D-@EVUj$Eg)=@6=E z@#L*7W|qCq*W!xRyz%}azq+NTrIL{{k5{wx9=$&5QFz+d73A@UdA>TE#nbrfC(X3B z8(6fZ$fI-Rsms(id`VH^EXwBij$f6Q%6pGy`z7a}PPWn1d>+=6lPmX*Un}gz{Ox!v z`WEl|IDGSOT%3|O*G+D{rZj7N?NbLjt(LV5jh=HqnA?U z8mrYxV|c!gMHxe<(a3REu1^wRwhaLAc*#s3m+W-80O+~e%iEuijH}D~<%`(7rkqDg z=TTZb2dmA-!DFZR&9(3NZQo)rQeiLlD~pmzCp{Of?FN2YE1pz;Th3*$^KYlnx3rR& zpyJ_&X0!Fj%Xs-G%lKj0eA3fW0mv9`|G!E9Ya~lJ`Po^X-Lx2KsErPD79Hj+q@gxm z{Mlkoes-3_qjQ5Er(oy{Vq#*j+H8D$A>2z=-J3vbyTSAQk0(04Sglr))oM!O z`@CekFQuSwX(c8)8igX37UN~i63tz8`Qdaso8^aiGyN2A&2A@2H4T81Uv&6wZ?)Oj zTifJC_?WSn~TqB!^hRw*Ad4e7J~3dFR=6G>_8NdnsMLm)G}au^{sd3m-1x^#e`g zF3xz6x-4W*PjVBduE|UGaf6#U1-aQM6tVOT40?@sz!ZhmW+Or>@p4-Zv4VXye+OW7 zc`+d&A#@sz?CP00DZSLHz!o=IttMHmrqgKTxg*zuw$4$Jkz99N$7-|j*1@mnmSvB7 zO=WExR-28GkWk(!3-#*~r7p`oB}P+1qz`Ts(`7QTajn||ZQHTiBYWfRy#Q?8q@~Mb zVxKK9=<$~3C;^C&N<0(TEz8Di8z5P&W>aZ0G0`z}8jaMCZ=XmZMWeykeJP-en=p}N zQr=uQi}bWqx=f~kF79@>Z|%3c-P>cc{E{db1WhEfM8nqKxzqiJbY}y$o33o;>9xz* zUQson-E%k07oQ_VqoK9kz%l!D08Tq~beT*pkf^ z4(PF1`pDEKqI8;gLeoonS}MI}GariryW_5*SlZ-;)XNs|tUjBo*UTssvHYZ9)NlJ) z_By_sKLd-UZ%SNTyvWApvWyA2xbs6QE?m4wVctygq*taq{STT*zcFP3uVFUm(>{fsnY2byQucdN-4PVNGGwlltbpW(qxPn=t@v%0g@(xlo8u|zNX$;Tj zL~B0)v5_*bKys%(iq>`m{r&x%z8c|~$V_b_07FC0fQu6zCMG;gOl!LV)wFmvmglg* zQ8R8V_1h;>NK8;+wORT1?%)IOmvT)cCaCB#nI=Te-qC2U(nDqS8QysRkk_a3)aCm} zq?bP(MW@xWs-)NJe1QW+nJCD~rsrxeyN)(b$ZgNE*Rg8RgYE+A=jS;+kQlUu{`Kmaq-Zo)ZC1bW*X)SP zB&*dleDyW$_FJ1<>AK4LvN>#CQ_ki!<><89`&-$rmo4DrXSKYw{l~;e&UndGvBREY zdBhz%GStSin-=p=&;OneA1vbs!`1gR{w#YP5zt^s>sevrzAfWX_)uEYBrfUeBv}`^qrW~HGWfKsmsDE zOQ*BGS9P4Wl`RF-yksh zy60FsZNNwVNWragKrk^ve!4rg7mMBdVO@#NOI{X#h4i#kMn*=saPcD79Zs)o<((?G z^^%CiJRf_Q&GJKDpRI*9vNO}^G#dG@zTAL%%&<4GWyKs~qN8as7&HHba-?wT_zK+{<0Kls4ZZI zwt3@|Ua`~d_}Me*beT*+rNNJ9iBKqFak*TiXf(`~bowmtSfv`EtT@NZqPks+{a z5!JMKPh8~>&n-znE|bw}==6Ccb0>biz(smmDwnVHu}ZPEji zzW45)-n*6<0^#-C^K4pKLR_4Zk&zJ&pEynB{*O3#>=aGS=dlkuD9FiX!}lillwCC0 z-?hEgU&dQ|syVhNu(h$+M6CR&JD%9FMMGhZ|GG+tIg8TOds)AHF)ylW?m2UG5RP)x z8t}<_w^)soA(EXPo(HDmU3a@1zaW|JX{#K%Oq;}A@|fXl@p%B-Ez8C%ib2W{N|$?g zkBuLwVmzkfoqdk=b-RuZv4S>9rqBJ{sq>hQNv?~2V>^dfL1TD6U)yB#J4cCkVw)_#|7FHwSFj&?I903+@}Q+?E}XNC3Nz=CN(ZZjK1= zEPb1Cd{SB4f1Go_kMMN4^{(v-b4ID$mhCyd8&;L{vU{JFmp>h)qCi-YZ!0DoBh||m zu>a`Eo9X_gaoZQ>jE+kpfEdXop55erJD^6gL|Bn;DJE=@t~lNAw+sx9aIkUClqxYW z=nj}aF^#ZTB`nJSYa&gTT1nApc>bmLzAo-6E0000