addProductImage static method

Future<Status> addProductImage(
  1. User user,
  2. SendImage image, {
  3. QueryType? queryType,
})

Send one image to the server. The image will be added to the product specified in the SendImage Returns a Status object as result.

Implementation

static Future<Status> addProductImage(
  User user,
  SendImage image, {
  QueryType? queryType,
}) async {
  var dataMap = <String, String>{};
  var fileMap = <String, Uri>{};

  dataMap.addAll(image.toData());
  fileMap.putIfAbsent(image.getImageDataKey(), () => image.imageUri);

  var imageUri = UriHelper.getUri(
    path: '/cgi/product_image_upload.pl',
    queryType: queryType,
    addUserAgentParameters: false,
  );

  return await HttpHelper().doMultipartRequest(
    imageUri,
    dataMap,
    files: fileMap,
    user: user,
    queryType: queryType,
  );
}