I'm currently making use of the "tmp" directory to store images before sending them off to Cloudinary.

When a user uploads an image, I'm noticing that watchdog is throwing multiple errors.
- Failed to load file
- Failed to get sub-folders under folder

I've narrowed down the problem to this function in the following file "cloudinary_stream_wrapper.module":

function cloudinary_stream_wrapper_load_resource($public_id, $options = array()) {
  // Load file resource locally first.
  if ($resource = cloudinary_stream_wrapper_resource_prepare($public_id)) {
    return $resource;
  }
  // Load folder first if public_id or options is empty.
  if (empty($public_id) || empty($options)) {
    // Return directory resource if public_id is a directory on Cloudinary.
    if ($resource = cloudinary_stream_wrapper_load_folder($public_id)) {
      return $resource;
    }
    // Return file resource on Cloudinary.
    if ($resource = cloudinary_stream_wrapper_load_file($public_id, $options)) {
      return $resource;
    }
  }
  else {
    // Return file resource on Cloudinary.
    if ($resource = cloudinary_stream_wrapper_load_file($public_id, $options)) {
      return $resource;
    }
    // Return directory resource if public_id is a directory on Cloudinary.
    if ($resource = cloudinary_stream_wrapper_load_folder($public_id)) {
      return $resource;
    }
  }

  return FALSE;
}

Before the new photo is uploaded, the module is searching for it on Cloudinary which is resulting in errors.

I've managed to get around the error by adding the following immediately within the "else" clause

if(cloudinary_stream_wrapper_resource_prepare($public_id) == FALSE){
      return FALSE;
    }

How can I get the module to not search for the image on Cloudinary before it exists there? Is there a better way to do this?

Comments

theonlyriddle created an issue. See original summary.

pq’s picture

Seems to me the problem isn't that it tries to load the file / folder. It should do that in order to figure out if there's already a file with that id so that it can either overwrite it or change the file id to avoid conflicts.

The problem is that the module is treating negative responses as errors, which they're not, they just mean that there isn't a file or folder with that id, but that shouldn't be an error state in and of itself.

grask0’s picture

Status: Active » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.