Problem Survey

We record the problems and investigation methods that our users often have during the use of FDS here.

The http method and header information used to send the request using the pre-igned link must match the parameters passed when the pre-signature was generated. If they are inconsistent, the server will return a 403 http return code if a check error is found.
Some http libraries automatically add the content-type header according to the uploaded file name suffix.
It is recommended that developers debugging for the first time use the SDK to generate a presigned link for uploading or downloading, and then use the command line tool curl to verify that the link is available.
Assume that the following Java code is used to generate pre-signed URLYOUR_PRESIGNED_URL

package com.xiaomi.infra.galaxy.fds.example;

import java.io.IOException;
import java.net.URI;
import java.util.Date;

import com.xiaomi.infra.galaxy.fds.client.FDSClientConfiguration;
import com.xiaomi.infra.galaxy.fds.client.GalaxyFDS;
import com.xiaomi.infra.galaxy.fds.client.GalaxyFDSClient;
import com.xiaomi.infra.galaxy.fds.client.credential.BasicFDSCredential;
import com.xiaomi.infra.galaxy.fds.client.credential.GalaxyFDSCredential;
import com.xiaomi.infra.galaxy.fds.client.exception.GalaxyFDSClientException;
import com.xiaomi.infra.galaxy.fds.model.HttpMethod;

public class FDSClient {

  private static final String APP_ACCESS_KEY = ""; // AppKey
  private static final String APP_ACCESS_SECRET = ""; // AppSecret

  private static final String BUCKET_NAME = ""; // Name of Bucket created
  private static final String OBJECT_NAME = ""; // Name of Object uploaded

  public static void main(String[] args)
      throws GalaxyFDSClientException, IOException {
    GalaxyFDSCredential credential = new BasicFDSCredential(
        APP_ACCESS_KEY, APP_ACCESS_SECRET);

    // Construct the GalaxyFDSClient object
    // set endpoint according to your needs.
    String endpoint = "awsbj0.fds.api.xiaomi.com"; // Confirm it is the same as the Bucket region
    FDSClientConfiguration fdsConfig = new FDSClientConfiguration(endpoint);
    fdsConfig.enableHttps(true);
    // do not upload object via cdn in this client
    fdsConfig.enableCdnForUpload(false);
    // download object via cdn in this client
    fdsConfig.enableCdnForDownload(true);
    GalaxyFDS fdsClient = new GalaxyFDSClient(credential, fdsConfig);

    // Generate pre-signed links for uploading files to specific Buckets
    URI uri = fdsClient.generatePresignedUri(BUCKET_NAME, "OBJECT_NAME",
        new Date(System.currentTimeMillis() + 1000 * 20 * 60), HttpMethod.PUT);
    System.out.println(uri.toASCIIString());
  }
}

The following is an upload with curl command

curl -v -X PUT -H "Content-Type:" 'YOUR_PRESIGNED_URL' -d 'Testing presigned url'

Sample output:

curl -v -X PUT -H "Content-Type:" 'https://awsbj0.fds.api.xiaomi.com/fds-demo/test.txt?GalaxyAccessKeyId=5xxxxxxx45&Expires=1486192975555&Signature=H3xxxxxxxQ=' -d 'Testing presigned url'
...
> PUT /fds-demo/test.txt?GalaxyAccessKeyId=5411741548045&Expires=1486192975555&Signature=H3xxxxxxxQ= HTTP/1.1
> User-Agent: curl/7.35.0
> Host: awsbj0.fds.api.xiaomi.com
> Accept: */*
> Content-Length: 21
> 
...
< HTTP/1.1 200 OK
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< Access-Control-Max-Age: 1728000
< Content-Type: application/json
< Date: Sat, 04 Feb 2017 07:07:02 GMT

* Server Tengine is not blacklisted
< Server: Tengine
< Content-Length: 146
< Connection: keep-alive
< 
* Connection #0 to host awsbj0.fds.api.xiaomi.com left intact
{"accessKeyId":"54xxxxxx45","bucketName":"fds-demo","expires":1488784022611,"objectName":"test.txt","signature":"fA7rxxxxxxxxgI="}

If there is no problem with the above command, but it reports 403 when uploading using your own http library, please use tcpdump and other tools to check whether the actual http request is consistent with the above command.
If you still have problems, please send the data of the curl command and the uploaded http library to us

Fragment Uploading

Before using a fragment upload, please carefully read the related restrictions

  • If you upload too many fragments (more than 400), the server will return 400
  • If the uploaded non-final fragment is too small (less than 5MB), the server will return 400
  • If the uploaded fragment is too large, the server will return 400
  • If there is a missing/duplicate fragment number in the patch list uploaded in the complete stage, the server will return 400
  • If you are using an older version of the android/iOS SDK, make sure that FDSClientConfiguration::uploadPartSize is set to be greater than 5 * 1024 * 1024 Refer to Method for Obtaining Network Request Content to check if the above problem occurs.
    If you still have problems, please send us the data received/sent in each phase of the captured fragment upload.

Resource Authorization/Return Code 403

After correctly granting the bucket or object permission to an account, 403 appears when the request is sent using the account's Access Key and Secret Key.

  • Check that it has been filled in with the correct GranteeId as described in the Quick Start
  • Confirm that the key is still valid
  • Confirm that the authorized bucket is the same bucket as the access
  • Confirm that the authorized bucket is in the same region as the accessed bucket
  • Confirm that the accessed object name does not start with ` and does not contain`

Method for Obtaining Network Request Content

During the tuning process you can capture the network packet, or enable the client log to view the request data received from the server and the request data sent to the server
The following is a method of grabbing a network request under Linux (provided that http is used instead of https), assuming the visited domain name is cnbj0.fds.api.xiaomi.com. If you do not know the domain you are visiting, you can remove host cnbj0.fds.api.xiaomi.com. Press ctrl-c after sending the request to end

sudo tcpdump -A host cnbj0.fds.api.xiaomi.com > tcpdump.log

If you are using the FDS Java SDK, you can set the following properties

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug");
System.setProperty("log4j.rootLogger", "INFO, stdout");

Other Methods

results matching ""

    No results matching ""