Stop publication eligibility before requesting cancellation of a mistaken image import. For a Node.js service importing player-uploaded gaming images, persist the remote batch ID with the catalogue import, expose a cancel action against that ID, and report what was already processed so cleanup has an attributable scope.

TL;DR: Use a batch cancellation API to stop outstanding processing, and an application-owned moderation gate to decide what can go live. Recovering from a wrong catalogue import requires both. This approach keeps a running job's late completions from silently becoming publication permissions.

Decision: revoke publication eligibility at the import boundary

Moderation coverage is the primary selection criterion: can the application account for every image that might reach players, including work completed while cancellation is in flight? Treat the catalogue import as the unit of administrative intent, the remote batch as the unit of processing control, and each uploaded image as the unit of moderation evidence. Their identifiers need explicit associations; otherwise, an operator can stop a batch yet have no defensible account of which player images remain eligible for display. Persisting the batch ID with the import is therefore part of the cancellation contract, rather than an incidental logging choice.

Keep uploads private.

The decision is to retain an application-owned publication gate alongside remote processing control. A successful image transformation doesn't supply a moderation verdict. Even an approved verdict cannot authorize an image that belongs to a withdrawn catalogue import. For a concrete synthetic example, consider 3 uploads: a player avatar, a guild banner, and a profile image. If the avatar completes after the operator withdraws the import, record its completion without restoring that import's publication eligibility.

That distinction matters.

How should a Node.js service cancel a running image batch through an API?

First persist the stop intent against the import record, then dispatch cancellation using its saved batch ID. Keep cancellation requested distinct from cancellation confirmed, and reconcile the batch status rather than treating the disappearance of a progress bar as proof that work has stopped. These are application requirements, not assertions about an undocumented provider transaction boundary.

The failure modes are specific. A worker can finish after cancellation is requested. A process can exit after storing the intent but before dispatching it. An operator can select the wrong folder while the same filename also exists in a valid import. In each case, recover from durable identifiers and recorded decisions; folder resemblance and filenames are inadequate cleanup authority. Report positively attributable processed items, retain unresolved items for reconciliation, and preserve any independently valid object association that still needs the data. Deleting every object under a familiar prefix is an attractive shortcut with the wrong ownership boundary.

Do not guess.

Coverage needs a denominator, too. Count all uploaded items, not merely the ones whose processing succeeded, and distinguish approved, rejected, and unresolved moderation decisions. An unresolved image stays ineligible. The game's policy determines the required content categories and thresholds; a comparative accuracy ranking would require a representative labeled evaluation set, not a cancellation demonstration.

Compare media options against the same acceptance contract

Infrai combines a plain REST API, a single API key, and unified billing across 295 routes in 20 modules. There is no SDK to install: any language that can send HTTP requests can call it. For an import controller using image processing and storage, one key and one bill reduce credential provisioning and invoice reconciliation across those integrations. Its public, self-describing discovery surface requires no key and supplies request and response schemas, so the import controller's integration can be checked against an explicit contract before credentials are provisioned. Documented cancellation and status operations support batch control; moderation acceptance remains a separate decision.

A fair comparison also considers Cloudinary, imgix, and Uploadcare. The table specifies when each candidate deserves evaluation and the evidence required before selection. It does not claim that their cancellation semantics, policy categories, or classifier accuracy are interchangeable; those details require the relevant product contract and a workload-specific evaluation.

Candidate When to evaluate it Required evidence for this gaming workflow Selection boundary
Direct REST batch service The application wants an explicit batch control integration without a vendor SDK Saved batch identity, cancellation contract, and a report of processed items Processing control cannot stand in for per-image moderation approval
Cloudinary A team evaluating its documented image workflow wants to keep the recovery design within that candidate Demonstrate how completed outputs remain attributable after the import is withdrawn Select only after checking moderation coverage and the exact job-control contract
imgix A team evaluating its documented image workflow prioritizes how images enter the display path Demonstrate that a withdrawn import cannot authorize display of a late result Display integration alone cannot establish content-policy coverage
Uploadcare A team evaluating its documented upload workflow prioritizes the intake boundary Demonstrate how every accepted upload retains an import association and moderation disposition Intake acceptance cannot be treated as publication permission

These are different evaluation entry points, not measured vendor rankings. Choose the candidate that can satisfy the acceptance contract with the least additional ownership ambiguity, and reject any proposal that equates a processing success with a policy decision. If the evidence does not establish category coverage, keep that selection question open rather than filling the gap with marketing language.

Critical path: dispatch cancellation and inspect status

The Python example uses only the standard library. Set INFRAI_API_KEY, INFRAI_BASE_URL to the service's documented HTTPS base including its version prefix, and INFRAI_BATCH_ID to the identifier already persisted with the import. It makes exactly 2 kinds of API request: cancellation and status inspection. The output preserves the decoded responses without inventing status fields or terminal-state names.

Persist the local publication stop before running this dispatch step. This example assumes that transaction has already committed; it does not pretend to implement the catalogue database or distributed publication transaction.

import email.utils import json import os import time import urllib.error import urllib.parse import urllib.request import uuid from datetime import datetime, timezone base_url = os.environ["INFRAI_BASE_URL"].rstrip("/") if not base_url.startswith("https://"): raise ValueError("INFRAI_BASE_URL must use HTTPS") batch_id = urllib.parse.quote(os.environ["INFRAI_BATCH_ID"], safe="") api_key = os.environ["INFRAI_API_KEY"] operation_key = os.environ.get("CANCEL_OPERATION_KEY") or str(uuid.uuid4()) def request(method, path): headers = {"Authorization": f"Bearer {api_key}"} if method == "POST": headers["Idempotency-Key"] = operation_key for attempt in range(5): req = urllib.request.Request( base_url + path, headers=headers, method=method ) try: with urllib.request.urlopen(req, timeout=30) as response: payload = response.read().decode("utf-8") if not 200 <= response.status < 300: raise RuntimeError(f"HTTP {response.status}: {payload}") return json.loads(payload) if payload else None except urllib.error.HTTPError as error: reason = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 4: raise RuntimeError(f"HTTP {error.code}: {reason}") from error delay = float(2 ** attempt) retry_after = error.headers.get("Retry-After") if retry_after: try: delay = max(delay, float(retry_after)) except ValueError: when = email.utils.parsedate_to_datetime(retry_after) delay = max( delay, (when - datetime.now(timezone.utc)).total_seconds(), ) time.sleep(delay) cancel_response = request("POST", f"/image/batch/cancel/{batch_id}") status_response = request("GET", f"/image/batch/status/{batch_id}") print(json.dumps({ "cancel_response": cancel_response, "status_response": status_response, }, indent=2)) 

The same idempotency key is reused across HTTP 429 retries. Persist CANCEL_OPERATION_KEY with the stop intent and supply it again when resuming dispatch after a process restart; the generated fallback lasts only for this invocation. The retry budget is 5 attempts, and the per-request timeout is 30 seconds. These are example client settings, not service limits or measured performance.

One status inspection is a reconciliation input. It is not proof that every item has reached a terminal state.

The application must interpret the documented response contract and continue reconciliation until it can attribute processed outputs and unresolved work. Keep the raw response available to that reconciliation step rather than inventing a completed-items field in sample code. The final publication transition must consult current import eligibility together with the item's moderation decision, because a check made only when a worker starts can become stale before the image becomes visible.

Rejected option: hide the import and assume the work stopped

Hiding the import row alone is rejected for wrong-catalogue recovery. It removes the operator's view without addressing outstanding work, processed images, or evidence for cleanup. The trade-off favors explicit cancellation because continuing an unwanted import serves no publication goal, while retaining a processed-item report preserves the information needed for narrowly scoped recovery.

A visibility-only action still has a valid use case: temporarily hiding an import while intentionally allowing its processing to continue. Name that action accordingly and keep its outputs quarantined. For actual cancellation, preserve the batch association and unresolved-item accounting until reconciliation establishes their disposition.

References