AWSPayload

@interface AWSPayload : NSObject

Utility methods for calcuating the signature for a payload. Payload == HTTP request body.

The payload signature is needed when calculating the request signature.

  • Returns the signature (SHA256 hash in lowercase hexadecimal) for the given payload data.

    Declaration

    Objective-C

    + (nonnull NSString *)signatureForPayload:(nonnull NSData *)data;

    Swift

    class func signature(forPayload data: Data) -> String
  • Calculates the signature (SHA256 hash in lowercase hexadecimal) for the given file.

    Declaration

    Objective-C

    + (void)signatureForPayloadWithFile:(nonnull NSURL *)fileURL
                        completionQueue:(nullable dispatch_queue_t)completionQueue
                        completionBlock:
                            (nonnull void (^)(NSString *_Nullable,
                                              NSError *_Nullable))completionBlock;

    Swift

    class func signatureForPayload(withFile fileURL: URL, completionQueue: DispatchQueue?, completionBlock: @escaping (String?, Error?) -> Void)

    Parameters

    fileURL

    A reference to the file that will be the body of the HTTP request (the payload).

    completionQueue

    The dispatch_block on which to invoke the completionQueue. If nil, the main thread will be used.

    completionBlock

    The block to invoke upon completion. The block will be invoked asynchronously on the completionQueue.

    • Calculates the signature (SHA256 hash in lowercase hexadecimal) for the given stream. *
    • - parameter: stream
    • A stream that representes the body of the HTTP request (the payload). *
    • - parameter: completionQueue
    • The dispatch_block on which to invoke the completionQueue.
    • If nil, the main thread will be used. *
    • - parameter: completionBlock
    • The block to invoke upon completion.
    • The block will be invoked asynchronously on the completionQueue.

    Declaration

    Objective-C

    + (void)signatureForPayloadWithStream:(nonnull NSInputStream *)stream
                          completionQueue:(nullable dispatch_queue_t)completionQueue
                          completionBlock:
                              (nonnull void (^)(NSString *_Nullable,
                                                NSError *_Nullable))completionBlock;

    Swift

    class func signatureForPayload(with stream: InputStream, completionQueue: DispatchQueue?, completionBlock: @escaping (String?, Error?) -> Void)
  • There are some API’s which still require a Content-MD5 header. For example: S3 Delete Multiple Objects

    Declaration

    Objective-C

    + (nonnull NSData *)rawMD5HashForPayload:(nonnull NSData *)data;

    Swift

    class func rawMD5Hash(forPayload data: Data) -> Data
  • There are some API’s which still require a Content-MD5 header. For example: S3 Delete Multiple Objects

    The hash is returned as a base64 encoded string.

    Declaration

    Objective-C

    + (nonnull NSString *)md5HashForPayload:(nonnull NSData *)data;

    Swift

    class func md5Hash(forPayload data: Data) -> String