Class FileService

java.lang.Object
com.bitheads.braincloud.services.FileService

public class FileService
extends Object
Created by bradleyh on 3/29/2016.
  • Constructor Details

  • Method Details

    • uploadFile

      public boolean uploadFile​(String cloudPath, String cloudFilename, boolean shareable, boolean replaceIfExists, String localPath, IServerCallback callback)
      Prepares a user file upload. On success the file will begin uploading to the brainCloud server. To be informed of success/failure of the upload register an IFileUploadCallback with the BrainCloudClient class.
      Parameters:
      cloudPath - The desired cloud path of the file
      cloudFilename - The desired cloud filename of the file
      shareable - True if the file is shareable.
      replaceIfExists - Whether to replace file if it exists
      localPath - The path and filename of the local file
      callback - The method to be invoked when the server response is received
      Returns:
      False if the file does not exist at the localPath Significant error codes: 40429 - File maximum file size exceeded 40430 - File exists, replaceIfExists not set
    • listUserFiles

      public void listUserFiles​(IServerCallback callback)
      List all user files
      Parameters:
      callback - The method to be invoked when the server response is received
    • listUserFiles

      public void listUserFiles​(String cloudPath, boolean recurse, IServerCallback callback)
      List user files from the given cloud path
      Parameters:
      cloudPath - File path
      recurse - Whether to recurse into sub-directories
      callback - The method to be invoked when the server response is received
    • deleteUserFile

      public void deleteUserFile​(String cloudPath, String cloudFilename, IServerCallback callback)
      Deletes a single user file.
      Parameters:
      cloudPath - File path
      cloudFilename - name of file
      callback - The method to be invoked when the server response is received Significant error codes: 40431 - Cloud storage service error 40432 - File does not exist
    • deleteUserFiles

      public void deleteUserFiles​(String cloudPath, boolean recurse, IServerCallback callback)
      Delete multiple user files
      Parameters:
      cloudPath - File path
      recurse - Whether to recurse into sub-directories
      callback - The method to be invoked when the server response is received
    • getCDNUrl

      public void getCDNUrl​(String cloudPath, String cloudFileName, IServerCallback callback)
      Returns the CDN url for a file object
      Parameters:
      cloudPath - File path
      cloudFileName - Name of file
      callback - The method to be invoked when the server response is received
    • cancelUpload

      public void cancelUpload​(String uploadId)
      Method cancels an upload. If an IFileUploadCallback has been registered with the BrainCloudClient class, the fileUploadFailed callback method will be called once the upload has been canceled.
      Parameters:
      uploadId - The id of the upload
    • getUploadProgress

      public double getUploadProgress​(String uploadId)
      Returns the progress of the given upload from 0.0 to 1.0 or -1 if upload not found.
      Parameters:
      uploadId - The id of the upload
      Returns:
      A progress from 0.0 to 1.0 or -1 if upload not found.
    • getUploadBytesTransferred

      public long getUploadBytesTransferred​(String uploadId)
      Returns the number of bytes uploaded or -1 if upload not found.
      Parameters:
      uploadId - The id of the upload
      Returns:
      The number of bytes uploaded or -1 if upload not found.
    • getUploadTotalBytesToTransfer

      public long getUploadTotalBytesToTransfer​(String uploadId)
      Returns the total number of bytes that will be uploaded or -1 if upload not found.
      Parameters:
      uploadId - The id of the upload
      Returns:
      The total number of bytes that will be uploaded or -1 if upload not found.