FilesApi

@interface FilesApi : NodeDependant

Provides access to Textile files related APIs

  • Add raw data to a Textile thread

    Declaration

    Objective-C

    - (void)addData:(nonnull NSString *)base64
           threadId:(nonnull NSString *)threadId
            caption:(nonnull NSString *)caption
         completion:(nonnull void (^)(int *_Nullable, NSError *_Nonnull))completion;

    Swift

    func addData(_ base64: String, threadId: String, caption: String, completion: @escaping (UnsafeMutablePointer<Int32>?, Error) -> Void)

    Parameters

    base64

    Raw data as base64 string

    threadId

    The thread id the data will be added to

    caption

    A caption to associate with the data

    completion

    A block that will get called with the results of the add operation

  • Add files to a Textile thread

    Declaration

    Objective-C

    - (void)addFiles:(nonnull NSString *)files
            threadId:(nonnull NSString *)threadId
             caption:(nonnull NSString *)caption
          completion:
              (nonnull void (^)(int *_Nullable, NSError *_Nonnull))completion;

    Swift

    func addFiles(_ files: String, threadId: String, caption: String, completion: @escaping (UnsafeMutablePointer<Int32>?, Error) -> Void)

    Parameters

    files

    A comma-separated list of file paths to add, paths can be file system paths, IPFS hashes, or an existing file hash that may need decryption

    threadId

    The thread id the files will be added to

    caption

    A caption to associate with the files

    completion

    A block that will get called with the results of the add operation

  • Share files already aded to a Textile thread to a Textile thread

    Declaration

    Objective-C

    - (void)shareFiles:(nonnull NSString *)target
              threadId:(nonnull NSString *)threadId
               caption:(nonnull NSString *)caption
            completion:
                (nonnull void (^)(int *_Nullable, NSError *_Nonnull))completion;

    Swift

    func shareFiles(_ target: String, threadId: String, caption: String, completion: @escaping (UnsafeMutablePointer<Int32>?, Error) -> Void)

    Parameters

    target

    The source thread target of the files to share

    threadId

    The thread id the files will be shared to

    caption

    A caption to associate with the files

    completion

    A block that will get called with the results of the add operation

  • Get a list of files data from a thread

    Declaration

    Objective-C

    - (id)list:(nonnull NSString *)threadId
        offset:(nullable NSString *)offset
         limit:(long)limit
         error:(NSError *_Nullable *_Nullable)error;

    Swift

    func list(_ threadId: String, offset: String?, limit: Int) throws -> Any

    Parameters

    threadId

    The thread to query

    offset

    The offset to beging querying from

    limit

    The max number of results to return

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    An object containing a list of files data

  • Get raw data for a file hash

    Declaration

    Objective-C

    - (void)content:(nonnull NSString *)hash
         completion:(nonnull void (^)(NSData *_Nullable, NSString *_Nullable,
                                      NSError *_Nonnull))completion;

    Swift

    func content(_ hash: String, completion: @escaping (Data?, String?, Error) -> Void)

    Parameters

    hash

    The hash to return data for

    completion

    A block that will get called with the results of content

  • Helper function to return the most appropriate image data for a minimun image width

    Declaration

    Objective-C

    - (void)imageContentForMinWidth:(nonnull NSString *)path
                           minWidth:(long)minWidth
                         completion:(nonnull void (^)(NSData *_Nullable,
                                                      NSString *_Nullable,
                                                      NSError *_Nonnull))completion;

    Swift

    func imageContent(forMinWidth path: String, minWidth: Int, completion: @escaping (Data?, String?, Error) -> Void)

    Parameters

    path

    The IPFS path that includes image data for various image sizes

    minWidth

    The width of the image the data will be used for

    completion

    A block that will get called with the results of content