Transfer files to an ECS instance using OSS

更新时间:
复制 MD 格式

This topic describes how to use Object Storage Service (OSS) to transfer large files to an ECS instance. This method is especially useful for instances that do not have a public IP address.

Solution overview

image

Transferring files to an ECS instance using Object Storage Service (OSS) involves two steps:

  1. Upload the file to an Object Storage Service (OSS) bucket that is in the same region as the destination ECS instance.

  2. From the ECS instance, download the file from OSS over the internal network.

Billing

  • Storing files in OSS incurs storage fees.

  • Alibaba Cloud does not charge data transfer fees for uploading files to OSS.

  • Downloading files from OSS to an ECS instance over the internal network does not incur data transfer fees if both resources are in the same region.

  • Uploading files to or downloading files from OSS incurs request fees.

For more information about OSS billable items, see Billable items.

Step 1: Upload the file to OSS

First, upload the file to an OSS bucket in the same region as your ECS instance. You can use the ossbrowser tool on your local computer to upload the file. Follow these steps:

Important

When you use ossbrowser to transfer a large file (10 GB or more) over the public network, the transfer might fail due to network instability. To transfer a file of 10 GB or more over a public network, see multipart upload.

  1. Activate Object Storage Service.

  2. Install and log on to ossbrowser.

    For more information, see Install ossbrowser 2.0 and Log on to ossbrowser 2.0.

  3. Create a bucket.

    1. Click Create Bucket in the upper-left corner. On the Create Bucket page, configure the following parameters and leave the others at their default values.

      • Bucket Name: Enter a name for the bucket.

      • Region: Select Specific Region, and then choose the region where your ECS instance is located. To view the region of your instance, see View instance information.

        image

    2. After completing the configuration, click Create.

  4. Upload the file to the bucket.

    1. Find the bucket that you created in the previous step and click its name.

      image

    2. Click Upload in the upper-left corner. Follow the on-screen instructions to upload your file and wait for it to complete.

      image

  5. Obtain the file URL.

    1. After the upload completes, find the file. In the Actions column, click image > Obtain URL.

    2. On the Obtain URL page, click Generate, and then click Copy URL.

      image

Step 2: Download the file from OSS

After you upload the file to OSS, you can log on to your instance to download the file over the internal network.

  1. Convert the public URL to an internal network URL.

    The URL you obtained in Step 1 is a public network URL. To create the internal network URL, add -internal before .aliyuncs.com in the URL. An instance in the same region can use this internal network URL to access the file; this avoids data transfer fees.

    Note

    For example, the internal network URL for the original address https://****.oss-cn-hangzhou.aliyuncs.com/demo-1.0.jar?****** is https://****.oss-cn-hangzhou-internal.aliyuncs.com/demo-1.0.jar?******.

  2. Download the file to the instance over the internal network.

    Windows instance

    1. Connect to the Windows instance. For more information, see Connect to a Windows instance by using Workbench.

    2. In the instance, open a web browser and enter the internal network URL from the previous step. When you access the URL, the file is downloaded to your instance.

      You can also install ossbrowser or ossutil on your Windows instance to download files. For more information, see Simple download.

    Linux instance

    1. Connect to the Linux instance. For more information, see Connect to a Linux instance by using Workbench.

    2. To download the file, run the following command. This topic uses the wget command as an example. You can use any command-line tool you prefer.

      wget -O <filename> '<file_internal_url>'

      Before you run the command, replace <filename> with your desired filename, and replace <file_internal_url> with the internal network URL from the previous step. For example, to download the file from the internal URL https://****.oss-cn-hangzhou-internal.aliyuncs.com/demo-1.0.jar?****** and save it as demo.jar, run the following command:

      wget -O demo.jar 'https://****.oss-cn-hangzhou-internal.aliyuncs.com/demo-1.0.jar?******'

(Optional) Step 3: Resource cleanup

After downloading the file, delete it from the OSS bucket to avoid unnecessary storage fees. For more information, see Delete objects.

Related documents

For an overview of OSS and its features, see What is Object Storage Service (OSS)?.