開発者コンソール
アクセスいただきありがとうございます。こちらのページは現在英語のみのご用意となっております。順次日本語化を進めてまいりますので、ご理解のほどよろしくお願いいたします。

SDK for iOS Uploading and Downloading Files

Uploading and downloading files using the SDK for iOS

Uploading a File

You can upload files to Amazon Drive using the ACDSKClient uploadFile:... method. A file can be uploaded to a specific folder using the ACDSKUploadFileRequest parents parameter. If no parents are specified, then the file is uploaded to the root folder.

  // Upload a file
  ACDSKUploadFileRequest *request = [ACDSKUploadFileRequest new];
  // Set the local path of the file to upload
  request.filePath = localFilePath;
  // Set the name to use for the file in Amazon Drive
  request.name = @"NewCloudDriveFile";
  // Set the parent folder for the new file
  request.parents = @[parentID];

  // Make asynchronous request using instance of ACDSKClient
  [client uploadFile:uploadFile:request fail:^(NSError *error) {
      // Handle failure
  } progress:^(float progressed) {
      // Handle progress
  } success:^(ACDSKUploadFileResponse *response) {
      // Handle success
      // response consists of a ACDSKNode
  }];

Allowing Duplicate Files

By default, Amazon Drive rejects uploads of a file that have the same SHA-256 hashing as an existing file in the same Amazon Drive. It is possible to override this behavior by setting the ACDSKUploadFileRequest suppressDeduplication parameter.

  // Allow duplicate binary file to be uploaded
  uploadFileRequest.suppressDeduplication = YES;

Downloading a File

Files can be downloaded from Amazon Drive using the ACDSKClient downloadFile:... method.

  // Download a file
  ACDSKDownloadFileRequest *request = [ACDSKDownloadFileRequest new];
  request.fileID = fileID;

  // Make asynchronous request using instance of ACDSKClient
  [client downloadFile:request fail:^(NSError *error) {
      // Handle failure
  } progress:^(float progressed) {
      // Handle progress
  } success:^(ACDSKDownloadFileResponse *response) {
      // Handle success
      // response contains the location of the downloaded file
  }];

Progress

Upload and Download Progress

Uploads and downloads both take a progress block, making it easy to keep track of the process. When updating the UI in response to an asynchrounous ACDSKClient callback such as progress, be sure to do so on the main thread.

  [client downloadFile:request fail:^(NSError *error) {
      // Handle failure
  } progress:^(float progressed) {
      // Handle progress
      dispatch_async(dispatch_get_main_queue(), ^{
          // Update UI on the main thread
      });
  } success:^(ACDSKDownloadFileResponse *response) {
      // Handle success
  }];

Support

If you have any questions, see the Developer Forum.