Create note with attachment with php and sugar api

Im trying to create a note in sugar and on my local install the following code worked fine

      $note = BeanFactory::getBean('Notes');
      $note->description        = $args['description'];
      $note->id                 = create_guid();
      $note->new_with_id        = true;
      $note->parent_type        = $args['parentType'];
      $note->modified_user_id   = $args['contact'];
      $note->created_by         = $args['contact'];
      $note->parent_id          = $args['parentID'];

      if (isset($args['file'])) {
        $note->filename           = $args['file'];
        $note->file_mime_type     = $args['file_mime_type'];
        $note->file_ext           = $args['file_ext'];
        $note->file_size          = $args['file_size'];
      }

      $note->save();

      if (isset($note->id) && !empty($note->id) && isset($args['file'])) {
        $result['success'] = true;
        $file = $GLOBALS['sugar_config']['upload_dir'] . '/' . $note->id;
        sugar_file_put_contents($file, base64_decode($args['file_content']));
      }

however ive packaged up my api to install it on our test then live cloud instance of sugar.

unfortunately I now get the error when i ty and install my package

File Issues

src/custom/clients/base/api/MC_UpgradesApi.php
Invalid usage of a function sugar_file_put_contents()

Im confused as I thought sugar_file_put_content was a standard sugar function but seems I'm not allowed to use it on cloud but cant find an alternative. anyone know how to add attachments to notes on a cloud instance via the api

Running Sugar Enterprise 9.0 on cloud