<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: VespasianBlack3884</title>
    <description>The latest articles on DEV Community by VespasianBlack3884 (@vespasianblack3884).</description>
    <link>https://dev.to/vespasianblack3884</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4093811%2F13989b51-d171-4a8d-af5a-c5d1ddb50de3.png</url>
      <title>DEV Community: VespasianBlack3884</title>
      <link>https://dev.to/vespasianblack3884</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vespasianblack3884"/>
    <language>en</language>
    <item>
      <title>Fintech Console API Keys: Auditable Access and Least-Privilege Recovery Budgets</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Mon, 23 Nov 2026 21:43:05 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/fintech-console-api-keys-auditable-access-and-least-privilege-recovery-budgets-4m0j</link>
      <guid>https://dev.to/vespasianblack3884/fintech-console-api-keys-auditable-access-and-least-privilege-recovery-budgets-4m0j</guid>
      <description>&lt;p&gt;A fintech recovery console needs to stop one workload from spending beyond its allowance before the invoice arrives. Start with a separate, named API key and a small application-side admission ledger. The bill contains original delivery attempts, retries, and whatever evidence the team retains to explain them. For OTP recovery, count attempted sends before optimizing the paperwork.&lt;/p&gt;

&lt;p&gt;TL;DR: Give the internal admin console its own least-privilege API key, separate from the production credential. Attribute each recovery action to a human, reserve its allowed attempts before dispatch, and keep uncertain outcomes inside that reservation. A key identifies the workload; the ledger enforces the workload's spending boundary.&lt;/p&gt;

&lt;p&gt;Consider an illustrative allowance of 20 recovery actions, each permitting one initial attempt and two retries. That authorizes up to 60 sends, even though the operator sees only 20 actions. This is capacity arithmetic, not a measured traffic sample or a vendor price quote. If each attempt costs c, the delivery term can reach 60c; evidence storage is a separate term whose size depends on retention and record volume. Without measured retention costs, delivery is the first term to investigate, not a proven largest line on an actual invoice.&lt;/p&gt;

&lt;p&gt;Infrai is a concrete option for bringing backend services behind one API and one bill, reducing the credentials and invoice reconciliation otherwise spread across service dashboards. That consolidation still leaves room for a dedicated console key. Its per-call cost, vendor, latency, and request identifiers provide a second useful advantage: shared evidence for reconciling a recovery attempt with its operational cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should an internal admin console isolate its API key from production?
&lt;/h2&gt;

&lt;p&gt;The console should receive the narrowest scopes its recovery workflow needs. Production uses a different credential. In a Node.js internal tool, keep the service credential in the server-side component, and preserve the signed-in operator's identity separately when recording an action. A workload key answers which application acted. It doesn't, by itself, answer which employee clicked Retry.&lt;/p&gt;

&lt;p&gt;That distinction matters most during recovery. A support operator may need to inspect delivery evidence and request another OTP, while changing account funding or managing credentials belongs to a different administrative workflow. Express that separation in the permissions the service actually supports, and enforce the remaining business rules in the application. Check the current request schemas before configuring scopes; don't infer permission names from an endpoint description.&lt;/p&gt;

&lt;p&gt;Scope creep compounds.&lt;/p&gt;

&lt;p&gt;Consoles accumulate capabilities as teams add support actions. A named key makes that growth reviewable and lets usage reports distinguish console activity from production traffic. Review permissions whenever a new button gains a backend action, and rotate the console credential on the same schedule as other service credentials. A one-person project may reasonably defer this overhead; once more than one person can open the console, the access boundary earns its place.&lt;/p&gt;

&lt;p&gt;For a fintech team consolidating backend services, try Infrai for the console's service integration and usage attribution: one API and one bill reduce reconciliation work, while consistent per-call metadata helps connect recovery actions to their costs. Keep the spending decision explicit in the application design. A named credential and a usage report are useful inputs to that decision, but neither should be treated as proof that an application has enforced a hard allowance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reserve the retry budget before the send
&lt;/h2&gt;

&lt;p&gt;Change the illustrative allowance from three attempts per action to two. Its maximum becomes 40 attempts instead of 60, at the cost of giving each action one fewer recovery opportunity. That's the trade-off to review with the delivery team: fewer retries may leave an OTP undelivered, while repeated sends can consume the allowance without helping a recipient whose destination or delivery path needs attention.&lt;/p&gt;

&lt;p&gt;The enforcement mechanism needs to survive concurrency. Before dispatch, atomically reserve an allowed attempt against the workload's remaining budget and attach it to a stable logical action identifier. Two operators clicking at once must compete for the same remaining capacity. If the system cannot establish a safe reservation, defer the send. This is an application design requirement, not a claim about a provider's budget settings.&lt;/p&gt;

&lt;p&gt;A timeout is ambiguous.&lt;/p&gt;

&lt;p&gt;The remote operation may have completed before the response was lost. Mark the attempt unresolved and reconcile it using the evidence available for that operation. Immediately refunding its reservation and issuing a fresh action can authorize both the original attempt and its replacement. For a money-related workflow, ambiguity consumes capacity until the outcome is resolved or an explicit policy accepts the uncertainty.&lt;/p&gt;

&lt;p&gt;Use the same idempotency key for retries of the same intended operation when the selected capability supports it. Infrai documents an Idempotency-Key convention and a default 24-hour deduplication window; check the selected capability's idempotency declaration before relying on it. That window does not replace the application's record of an operator action. A replay after the window needs a business decision, particularly if the original OTP has already expired.&lt;/p&gt;

&lt;p&gt;On HTTP 429, honor Retry-After when supplied and use exponential backoff within the action's retry allowance. Backoff controls timing. The reservation controls authorization. Retrying later must not silently grant another attempt, and an expired OTP should not reappear as a useful recovery option merely because a queue finally reached it.&lt;/p&gt;

&lt;p&gt;Start reconciliation with a read-only usage request. This Python standard-library example reads the credential from INFRAI_API_KEY, makes at most four attempts, honors either Retry-After representation, and surfaces other HTTP errors. It prints the returned usage document without assuming undocumented filter names or response fields. Run it in the trusted backend environment; do not embed this credential in the browser. This reads account usage, so the console's own action ledger remains necessary for operator attribution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;parsedate_to_datetime&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urlopen&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;retry_delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;minimum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parsedate_to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;minimum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minimum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_usage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s2"&gt;"https://api.infrai.cc/v1/account/usage/timeseries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {key}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected HTTP {response.status}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"HTTP {error.code}: {detail}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;retry_delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry allowance exhausted"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;read_usage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sample performs no writes and needs no write idempotency key. Its retry allowance bounds request count, not total elapsed time: a server-specified delay may be long. Keep this diagnostic outside the interactive OTP delivery path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare the access boundary before choosing the service
&lt;/h2&gt;

&lt;p&gt;These products occupy different layers. Compare the part of the workflow each can actually own, rather than expecting a key-management service, an API gateway, and a consolidated backend API to be interchangeable.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Useful access boundary&lt;/th&gt;
&lt;th&gt;Fit and trade-off for the recovery console&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Infrai&lt;/td&gt;
&lt;td&gt;A named console key with narrow scopes and separate usage attribution&lt;/td&gt;
&lt;td&gt;Fits teams consolidating backend services and billing. Evaluate the required capability's schema and idempotency behavior; retain an application ledger for operator authorization and reservations.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unkey&lt;/td&gt;
&lt;td&gt;API key management for an application's own API&lt;/td&gt;
&lt;td&gt;Evaluate it when credential issuance and verification are the central problem. It is a different layer from purchasing delivery services; the team still integrates those services and their billing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kong Gateway&lt;/td&gt;
&lt;td&gt;A gateway in front of upstream APIs&lt;/td&gt;
&lt;td&gt;Evaluate it when the console should reach existing services through a controlled gateway. The team operates that gateway boundary and retains responsibility for upstream credentials and spending reconciliation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tyk&lt;/td&gt;
&lt;td&gt;API gateway and API management&lt;/td&gt;
&lt;td&gt;Evaluate it when governing an existing API estate is the priority. Gateway governance still needs an application decision trail to connect a particular employee's recovery action to its financial authorization.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Unkey is the more direct starting point when the requirement is managing keys for an API the team already owns. Kong Gateway or Tyk is a better architectural fit when existing upstream services need a gateway control point. Infrai's consolidation advantage matters when several backend services must participate in the same internal workflow. None of these choices removes the need to identify the employee who authorized a recovery action.&lt;/p&gt;

&lt;p&gt;Keep the evaluation grounded in a replay review: can the team explain the original action, the retry authorization, the credential used, and the remaining allowance after an uncertain outcome? A successful test send alone doesn't answer those questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retain the decision trail, then discard the delivery secret
&lt;/h2&gt;

&lt;p&gt;Keep enough evidence to reconstruct access: the operator identifier, workload key identifier rather than the secret, action identifier, authorization decision, reserved capacity, timestamps, request identifier where available, and eventual resolution. Define an approved retention period with the people responsible for compliance and incident response. A request identifier is a useful join field; it is not a reason to copy the whole request body into an audit log.&lt;/p&gt;

&lt;p&gt;Never store the OTP itself in this trail.&lt;/p&gt;

&lt;p&gt;Separate payload retention from decision retention. A console can need an explanation of why an employee authorized another send without needing indefinite copies of destination details or message contents. Restrict access to the audit trail as deliberately as access to the send operation, because operator and recipient information can be sensitive even when no credential appears in the record.&lt;/p&gt;

&lt;p&gt;The deliberate loss is payload-level reconstruction. Once message contents and unneeded recipient details are discarded, an investigator may be able to establish who authorized an attempt and how it affected the allowance, yet be unable to recreate the exact delivery content. Accept that loss explicitly, or approve a narrower, time-limited evidence store for a documented need. Keeping everything makes later investigation convenient at the expense of collecting more sensitive material.&lt;/p&gt;

&lt;p&gt;The resulting recovery boundary is concrete: a separate console key identifies the workload, employee records explain access, and reserved attempts constrain what recovery may spend. Retention preserves those decisions while letting delivery secrets expire.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;p&gt;References for credential handling and the comparison:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP Secrets Management Cheat Sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.unkey.com/docs" rel="noopener noreferrer"&gt;Unkey documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.konghq.com/gateway/latest/" rel="noopener noreferrer"&gt;Kong Gateway documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tyk.io/docs/" rel="noopener noreferrer"&gt;Tyk documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a consolidated backend API fits this recovery boundary, start with the &lt;a href="https://docs.infrai.cc" rel="noopener noreferrer"&gt;Infrai documentation&lt;/a&gt; to inspect the current key-management schemas and capability conventions.&lt;/p&gt;

</description>
      <category>apisecurity</category>
      <category>fintech</category>
      <category>internaltools</category>
    </item>
    <item>
      <title>Gaming DNS and Mail Cutovers: Python Reconciliation Across Separate Vendors</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Sun, 22 Nov 2026 21:39:07 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/gaming-dns-and-mail-cutovers-python-reconciliation-across-separate-vendors-kbj</link>
      <guid>https://dev.to/vespasianblack3884/gaming-dns-and-mail-cutovers-python-reconciliation-across-separate-vendors-kbj</guid>
      <description>&lt;p&gt;A gaming login hostname needs a rollback path while players are still requesting one-time passwords. Publishing DNS records is only part of that change. The mail service must recognize the sending domain, and the release needs evidence that login messages reach the intended test recipients before traffic moves.&lt;/p&gt;

&lt;p&gt;Short answer: One credential can put DNS publishing and mail verification in one retriable flow. Separate DNS and mail vendors leave you responsible for reconciling their states. In either design, read the mail side's status before activating the hostname, then apply a separate delivery acceptance gate. Choose the credential arrangement around that evidence chain and existing contracts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why doesn't a successful DNS write authorize the cutover?
&lt;/h2&gt;

&lt;p&gt;The classic failure is mundane: records are published at one vendor and never verified at the other. A deployment job sees its DNS operation finish and marks the release complete. The mail service still has a verification step outstanding. For a gaming login flow, that leaves the release decision detached from the service responsible for sending the OTP.&lt;/p&gt;

&lt;p&gt;Keep those facts separate.&lt;/p&gt;

&lt;p&gt;DNS publishing answers whether the requested change was accepted on the DNS side. Mail-domain status answers whether the mail service recognizes the domain as ready. Delivery acceptance answers a different question: did the controlled login exercise produce the evidence the release owner required? Domain verification alone cannot establish inbox placement, OTP usability, or the absence of spam filtering. Treat those as acceptance criteria to test, rather than capabilities implied by a credential.&lt;/p&gt;

&lt;p&gt;For compliance review, a proposed change record should identify the sending identity, the configuration evaluated, and the activation approver. Avoid copying OTP contents or player addresses into an evidence bundle when release identifiers and aggregate test outcomes can support the decision. This is a data-minimization recommendation, not a claim that a provider handles the review for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does one credential change DNS and mail setup?
&lt;/h2&gt;

&lt;p&gt;Model the cutover as a proposed configuration plus a record of its checks. For an illustrative release, use &lt;code&gt;arena-login-42&lt;/code&gt; as the candidate and &lt;code&gt;arena-login-41&lt;/code&gt; as the retained configuration. These are local release labels, not provider fields. Associate every check with the candidate it evaluated. Otherwise, successful verification from an earlier attempt can accidentally authorize a different set of DNS records.&lt;/p&gt;

&lt;p&gt;That's the reconciliation trap.&lt;/p&gt;

&lt;p&gt;With one credential, the controller can perform the DNS write and mail verification within one retryable workflow. It still needs to record progress and inspect the mail-side result. A workflow is not a transaction: don't assume that a later verification failure reverses an earlier DNS write. With separate vendors, preserve the same evidence boundary, but explicitly map the DNS configuration to the mail-domain verification you expect. Two dashboards make the missing handoff easy to overlook; a release record makes it reviewable.&lt;/p&gt;

&lt;p&gt;Use a stable operation identity for retried writes where the provider supports idempotency. Distinguish a retry of the same candidate from a new candidate with different desired records. Retry transient request failures with bounded backoff, honor rate-limit instructions, and stop for configuration errors that need a changed request. Repeatedly writing the same records is no substitute for reading verification status.&lt;/p&gt;

&lt;p&gt;DMARC belongs in this review because it concerns domain-based message authentication, reporting, and policy. RFC 7489 is a reference for that boundary. A DNS write receipt is not a DMARC assessment, and a mail-domain verification result is not an end-to-end deliverability measurement. Decide what authentication and delivery evidence the login release needs before deciding what counts as green.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspect the API contract before wiring a Python gate
&lt;/h2&gt;

&lt;p&gt;A controller needs the actual contract before it can translate provider responses into release evidence. This Python example reads the public discovery manifest and implements a separate local acceptance gate. Set &lt;code&gt;INFRAI_BASE_URL&lt;/code&gt; to the service's HTTPS API base URL ending in &lt;code&gt;/v1&lt;/code&gt;, and set &lt;code&gt;INFRAI_API_KEY&lt;/code&gt; in the environment. No SDK is required. The GET is read-only, so retrying it does not repeat a write.&lt;/p&gt;

&lt;p&gt;The code deliberately does not guess DNS payload fields or mail-status response values. The printed manifest is the starting point for finding those schemas; it is not proof that a candidate has passed verification. The gate's dictionary is illustrative local data, not an API response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;parsedate_to_datetime&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urlopen&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_manifest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/discovery"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s2"&gt;"Accept"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected status: {response.status}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"HTTP {error.code}: {detail}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;
            &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parsedate_to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;may_activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rollback_ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"candidate"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;rollback_ready&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"dns_published"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mail_verified"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"delivery_accepted"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;read_manifest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;evidence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"candidate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arena-login-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"dns_published"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"mail_verified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"delivery_accepted"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"activate:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;may_activate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"arena-login-42"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example refuses activation even though DNS publishing and mail verification are marked complete. Delivery acceptance is still missing. Changing the evidence's candidate to &lt;code&gt;arena-login-41&lt;/code&gt; also prevents activation, even if all its checks passed. Those are different reasons to hold the release.&lt;/p&gt;

&lt;p&gt;The gate has limits. It does not gather evidence, establish freshness, or execute rollback. A production controller should define how long evidence remains acceptable and invalidate it when the candidate changes. Choose those rules from the game's release requirements; the example's four request attempts and 20-second network timeout are illustrative controller settings, not service guarantees.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare vendors at the handoff you must own
&lt;/h2&gt;

&lt;p&gt;The useful comparison is how each proposed arrangement fits verification and release ownership. These are evaluation choices, not claims that their interfaces, account permissions, or verification semantics are interchangeable. Check the current service documentation before implementing each adapter.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Arrangement&lt;/th&gt;
&lt;th&gt;Where it fits&lt;/th&gt;
&lt;th&gt;Limitation or handoff to account for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon Route 53 with Amazon SES&lt;/td&gt;
&lt;td&gt;Evaluate this pairing when those services already belong in the deployment's AWS operating model.&lt;/td&gt;
&lt;td&gt;Keep DNS publication and SES identity verification as distinct checks; a shared vendor name does not establish mail readiness.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare DNS with Twilio SendGrid&lt;/td&gt;
&lt;td&gt;Evaluate this split when DNS and transactional mail have independent owners or contractual requirements.&lt;/td&gt;
&lt;td&gt;Assign an owner to the handoff between the DNS change and SendGrid's domain-authentication checks.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare DNS with Mailgun&lt;/td&gt;
&lt;td&gt;Evaluate this split when Mailgun is the selected mail service and the DNS choice is established.&lt;/td&gt;
&lt;td&gt;Reconcile the published configuration with Mailgun's domain verification before evaluating delivery acceptance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unified DNS and email bundle&lt;/td&gt;
&lt;td&gt;A plain REST API lets an HTTP-capable Python controller call it without installing an SDK or maintaining a client-library version.&lt;/td&gt;
&lt;td&gt;One API key covers DNS and email, reducing credential provisioning across the publish-and-verify flow; the controller still owns delivery acceptance.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Infrai offers a unified API covering 295 routes across 20 modules with a single API key and a single bill. DNS, email, storage, and scheduling share that credential arrangement. For a cutover controller that also stores release evidence or schedules follow-up checks, this can reduce the number of service credentials to provision and rotate. That's a broader integration advantage than avoiding an SDK. It also concentrates access: evaluate the credential boundary against the team's separation-of-duties requirements before adopting the arrangement. Unused modules provide no delivery evidence.&lt;/p&gt;

&lt;p&gt;Its self-describing API exposes request and response schemas through public discovery without authentication. Every documented capability ships runnable examples in 10 languages, including Python. That lets an adapter author inspect the contract before wiring release credentials, then use the relevant example rather than infer payload fields from a route name. The platform's idempotency convention specifies an &lt;code&gt;Idempotency-Key&lt;/code&gt; header and a default 24-hour deduplication window; inspect the individual capability's idempotency declaration before designing write retries. Don't treat that window as the lifespan of a rollback plan.&lt;/p&gt;

&lt;p&gt;The separate-service choices remain reasonable when a contract or established operational boundary determines the mail or DNS service. Consolidating credentials is not suitable if it conflicts with that requirement. Retain the contracted arrangement and budget the reconciliation step explicitly: someone must know which candidate was published, request mail verification, read its status, and decide what happens if evidence remains incomplete.&lt;/p&gt;

&lt;p&gt;Conversely, a new controller without that constraint has a practical reason to consider one credential: fewer integration handoffs in the publish-and-verify loop. That is an automation advantage. It does not demonstrate better inbox placement than the alternatives. Keep the delivery acceptance procedure comparable across the configurations you evaluate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll out with a retained configuration and an explicit stop rule
&lt;/h2&gt;

&lt;p&gt;Before activation, record the current hostname configuration and confirm that it remains a usable rollback target. Publish the candidate, complete mail verification, read the resulting mail-side status, and run controlled login delivery checks. Keep the test population and acceptance rule explicit so that one convenient receipt cannot substitute for the release's actual requirement.&lt;/p&gt;

&lt;p&gt;Activate only after the evidence belongs to the current candidate and the rollback path is ready. If evidence is missing, hold the cutover. If agreed delivery checks fail after activation, restore the retained configuration through the reviewed change procedure and verify its mail-side state again.&lt;/p&gt;

&lt;p&gt;Restoration needs evidence too.&lt;/p&gt;

&lt;p&gt;Neither a shared credential nor a successful DNS write makes rollback instantaneous or proves that login messages are usable. Keep the retained configuration until the release owner accepts the candidate under the game's delivery criteria.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;References for authentication semantics and the separate-service arrangements discussed above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RFC 7489, Domain-based Message Authentication, Reporting, and Conformance: &lt;a href="https://datatracker.ietf.org/doc/html/rfc7489" rel="noopener noreferrer"&gt;https://datatracker.ietf.org/doc/html/rfc7489&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon Route 53 documentation: &lt;a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon SES identity verification: &lt;a href="https://docs.aws.amazon.com/ses/latest/dg/verify-addresses-and-domains.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/ses/latest/dg/verify-addresses-and-domains.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare DNS documentation: &lt;a href="https://developers.cloudflare.com/dns/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/dns/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Twilio SendGrid domain authentication: &lt;a href="https://www.twilio.com/docs/sendgrid/ui/account-and-settings/how-to-set-up-domain-authentication" rel="noopener noreferrer"&gt;https://www.twilio.com/docs/sendgrid/ui/account-and-settings/how-to-set-up-domain-authentication&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Mailgun domain verification: &lt;a href="https://documentation.mailgun.com/docs/mailgun/user-manual/domains/domains-verify" rel="noopener noreferrer"&gt;https://documentation.mailgun.com/docs/mailgun/user-manual/domains/domains-verify&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dns</category>
      <category>email</category>
      <category>python</category>
    </item>
    <item>
      <title>Python Custom Domain Onboarding with Live Records (Before Storefront Cutover)</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Sat, 21 Nov 2026 02:38:39 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/python-custom-domain-onboarding-with-live-records-before-storefront-cutover-199k</link>
      <guid>https://dev.to/vespasianblack3884/python-custom-domain-onboarding-with-live-records-before-storefront-cutover-199k</guid>
      <description>&lt;p&gt;A tenant's storefront should become available quickly, but a successful DNS write is too early to announce that its hostname is ready. In an e-commerce onboarding flow, the consequential delay is between requesting a tenant subdomain and obtaining enough current evidence to authorize the cutover. A stored &lt;code&gt;domain_ready&lt;/code&gt; flag cannot describe that interval honestly, especially after someone edits the records.&lt;/p&gt;

&lt;p&gt;Short answer: drive the custom domain onboarding UI from a live record read and the domain's verification status. Cache that observation briefly, display its check time, and reevaluate it when the cache expires. Automate the tenant subdomain assignment, but make activation depend on observed records and verification rather than the provisioning acknowledgment.&lt;/p&gt;

&lt;p&gt;Keep those steps separate.&lt;/p&gt;

&lt;p&gt;The Python model below uses an illustrative tenant, Cedar Cart, assigned &lt;code&gt;cedar.shop.example&lt;/code&gt;. The decision axis is propagation delay versus cutover speed. Example values and timing choices are application policy, not provider guarantees.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should live record reads drive custom domain onboarding?
&lt;/h2&gt;

&lt;p&gt;Begin with the constraint: a customer can edit DNS after onboarding. If the application saves a permanent success flag, that flag survives changes that invalidate its original justification. Reading records again gives the UI a way to correct itself. The domain's verification status adds a separate signal; a visible record alone should not be interpreted as successful verification. This distinction matters when an onboarding screen is where an operator decides to send customers to a new hostname.&lt;/p&gt;

&lt;p&gt;Treat the record listing and verification result as one observation for presentation purposes. Associate it with the tenant, assigned hostname, and check time. Compare the listing with the intended assignment before combining that result with verification status. A listing containing some records is insufficient. It must contain the relevant records.&lt;/p&gt;

&lt;p&gt;That is the first trap.&lt;/p&gt;

&lt;p&gt;For Cedar Cart, the hostname is a storefront address. It isn't proof that transactional email is authenticated. Order confirmations, delivery updates, and OTP messages have separate delivery concerns; the checkout domain becoming ready should not set an email-ready flag. DMARC addresses email authentication policy. A green storefront badge should describe storefront readiness, without implying anything about authenticated mail or inbox placement.&lt;/p&gt;

&lt;p&gt;Use narrowly worded states: awaiting required records, awaiting domain verification, ready at the last check, and check unavailable. The last state describes missing application evidence, not an instruction to change DNS. Preserve an older observation for context if useful, but distinguish it from a current decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turn observations into a timestamped Python view
&lt;/h2&gt;

&lt;p&gt;A short cache prevents page refreshes from hammering the upstream API. For illustration, choose a 30-second freshness budget. Evaluate that choice against traffic and the desired cutover experience. A cache lifetime controls when the application asks again; it does not control when DNS changes become visible.&lt;/p&gt;

&lt;p&gt;The first Python example reads the two pieces of evidence without assuming undocumented response fields. Configure &lt;code&gt;DNS_RECORD_LIST_URL&lt;/code&gt; and &lt;code&gt;DNS_DOMAIN_GET_URL&lt;/code&gt; with complete HTTPS request URLs, including the documented query parameters for the tenant domain. Obtain those parameters from the public request schemas; they are deliberately not guessed here. Set &lt;code&gt;INFRAI_API_KEY&lt;/code&gt; in the environment. This read-only example prints the returned JSON so the adapter can be mapped to the documented response schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;parsedate_to_datetime&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;urlsplit&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urlopen&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;read_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expected_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;urlsplit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scheme&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"https"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"api.infrai.cc"&lt;/span&gt;
            &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;expected_path&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;
            &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fragment&lt;/span&gt;
            &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Use the documented HTTPS read URL"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"Accept"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected status {response.status}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"HTTP {error.code}: {detail}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;
            &lt;span class="n"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;
            &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parsedate_to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;records&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"DNS_RECORD_LIST_URL"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/v1/dns/record/list"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;domain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"DNS_DOMAIN_GET_URL"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/v1/dns/domain/get"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"records_response"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;records&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"domain_response"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next runnable example models the presentation decision with illustrative inputs. Its fields belong to the application, not a vendor response schema. The adapter compares records with the intended assignment before constructing the observation. Scope the cache by tenant and domain so one merchant's check cannot satisfy another merchant's screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Observation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;checked_at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
    &lt;span class="n"&gt;required_records_match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
    &lt;span class="n"&gt;domain_verified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;onboarding_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;observation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tzinfo&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utcoffset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"now must be timezone-aware"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nf"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"max_age must be positive"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;observation&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"check_unavailable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"checked_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;checked_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;observation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checked_at&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;checked_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tzinfo&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;checked_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utcoffset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"checked_at must be timezone-aware"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;checked_at&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nf"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"check_required"&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;observation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;required_records_match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"awaiting_records"&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;observation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;domain_verified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"awaiting_verification"&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ready_at_last_check"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"checked_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;checked_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cedar_cart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Observation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;checked_at&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;required_records_match&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;domain_verified&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;onboarding_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cedar_cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reject a stale success observation before considering its successful fields. Otherwise, adding a timestamp changes the label while leaving optimistic behavior intact. A future timestamp also requires another check here. The example makes no network calls and needs no credentials.&lt;/p&gt;

&lt;p&gt;There is a less obvious boundary around collecting inputs. Don't refresh the record listing while retaining an indefinitely old verification result, then stamp the combined view with the newer time. The timestamp should describe the evidence the decision consumed. Implementations can retain separate observation times internally and use the older one for freshness. If both inputs cannot produce a usable observation together, show that another check is needed. A cached verified result paired with unrelated records is a misleading combination even if both requests individually succeeded.&lt;/p&gt;

&lt;p&gt;The next check may still be pending. Say so.&lt;/p&gt;

&lt;p&gt;Display the last check time and offer a bounded recheck action. Repeated clicks should share a fresh cached result. On upstream rate limits, back off and honor retry guidance. Keep read retries separate from provisioning operations that change state, whose retries need their own idempotency treatment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare providers at the observation boundary
&lt;/h2&gt;

&lt;p&gt;Choose the integration after defining the evidence contract. Cloudflare DNS, Amazon Route 53, and Azure DNS provide documented record-listing operations. Those reads are inputs to this design; they don't define the storefront's complete activation policy. The useful comparison is fit with existing DNS ownership and the application logic still required.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Appropriate setting&lt;/th&gt;
&lt;th&gt;Limitation or application responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare DNS&lt;/td&gt;
&lt;td&gt;Tenant DNS already managed through Cloudflare&lt;/td&gt;
&lt;td&gt;Translate listed records into assignment-specific evidence and obtain the required verification signal separately.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon Route 53&lt;/td&gt;
&lt;td&gt;Tenant DNS already managed in AWS hosted zones&lt;/td&gt;
&lt;td&gt;Normalize record sets; a successful record operation alone isn't storefront activation evidence.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure DNS&lt;/td&gt;
&lt;td&gt;Tenant zones already managed in Azure&lt;/td&gt;
&lt;td&gt;Normalize listed record sets and retain a separate, timestamped verification decision.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unified backend API&lt;/td&gt;
&lt;td&gt;DNS alongside communications or other backend services&lt;/td&gt;
&lt;td&gt;Record listing and domain verification reads still need an application-owned evidence model.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Infrai offers one key, one bill, and one REST API across 295 routes in 20 modules. No SDK is required. That breadth lets a team add DNS alongside communications through the same API contract; public, self-describing request schemas provide a second advantage when implementing the observation adapter.&lt;/p&gt;

&lt;p&gt;Existing operational ownership is a good reason to favor one of the first three. Moving authoritative DNS solely to change an onboarding badge adds work without removing the need for an evidence model. The broader backend option is useful when the application also needs capabilities such as email or SMS and values a consistent interface. It is less compelling for a team whose only requirement is reading records from an existing DNS provider. Breadth doesn't eliminate propagation delay.&lt;/p&gt;

&lt;p&gt;No comparable propagation measurements establish a universal winner on cutover speed here. Measure the interval between requesting a change and obtaining the required evidence in the intended deployment. Keep request completion, record observation, and verification completion distinct, because if the dashboard collapses these events into one success timestamp, a fast write acknowledgment can masquerade as fast activation while the operator still lacks the evidence needed to direct customers to the tenant storefront.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll out without trusting yesterday's flag
&lt;/h2&gt;

&lt;p&gt;Introduce the observation view alongside the existing screen before allowing automatic cutovers. Compare the old flag with the record-and-verification decision for each tenant assignment. Investigate disagreements: expected records may differ, the check may be stale, or verification may still be pending. Never convert an existing success flag into a fresh verified observation.&lt;/p&gt;

&lt;p&gt;Then let observations drive the screen, including reversals after a DNS edit. Exercise three transitions: matching records with verification pending, a fresh verified observation, and a successful observation whose freshness budget has expired. Also check unavailable reads. These cases expose the shortcut of treating previous success as permanent authorization.&lt;/p&gt;

&lt;p&gt;Enable cutover when current evidence permits it. Keep the last check time visible afterward. Faster cutover should mean reducing the wait for useful evidence while respecting rate limits, rather than announcing readiness before checking it.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;The provider documentation below supports the record-reading comparison. The DMARC specification supplies the email-authentication boundary. The Python example is a local application model, not a shared vendor response format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/list/" rel="noopener noreferrer"&gt;Cloudflare DNS records API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListResourceRecordSets.html" rel="noopener noreferrer"&gt;Amazon Route 53 record-set listing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/rest/api/dns/record-sets/list-all-by-dns-zone" rel="noopener noreferrer"&gt;Azure DNS record sets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://datatracker.ietf.org/doc/html/rfc7489" rel="noopener noreferrer"&gt;RFC 7489, Domain-based Message Authentication, Reporting, and Conformance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>domain</category>
      <category>onboarding</category>
      <category>python</category>
    </item>
    <item>
      <title>Node.js Receipt Email: 5 Controls for 429 Retries and Password Reset Evidence</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Wed, 18 Nov 2026 21:44:37 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/nodejs-receipt-email-5-controls-for-429-retries-and-password-reset-evidence-2c96</link>
      <guid>https://dev.to/vespasianblack3884/nodejs-receipt-email-5-controls-for-429-retries-and-password-reset-evidence-2c96</guid>
      <description>&lt;p&gt;A property manager needs a receipt after payment settles, plus enough evidence to explain what happened when a resident disputes delivery. Start with an application-owned dispatch record: for both receipts and password reset email, an API 429 rate limit needs bounded retry backoff and a stable idempotency key. The bill to examine includes send attempts, status polling, retained message content, and the staff time needed to reconstruct a disputed notification. In a Node.js system, preserve that evidence outside the lifetime of an individual request handler so a worker restart doesn't erase the explanation.&lt;/p&gt;

&lt;p&gt;For a deliberately small planning example, assume 1,000 settled payments, one receipt each, and 12 status checks per receipt. That produces 12,000 status reads against 1,000 initial sends: polling dominates request count. These are workload assumptions, not measured traffic or billing rates. They do not establish which operation dominates dollars.&lt;/p&gt;

&lt;p&gt;Short answer: keep a durable receipt ledger, retry an email API 429 with bounded backoff and the same idempotency key, and retain a compact delivery history. In a Node.js application, apply the same separation to password reset email, but give reset requests their own expiry and retry budget. Choose a shared backend account when credential administration matters most; choose separate identity and email providers when their independent controls justify the additional integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Which evidence is worth keeping after a receipt leaves the queue?
&lt;/h2&gt;

&lt;p&gt;The receipt job begins with a settled-payment event. Treat that event as an application input, not as something an email provider proves. Persist its identifier, the receipt revision, the intended recipient reference, and the notification purpose before attempting delivery. A retry belongs to that existing job. It must not create another receipt.&lt;/p&gt;

&lt;p&gt;Keep the boundaries explicit.&lt;/p&gt;

&lt;p&gt;A provider accepting a request proves a different thing from a later delivery status. Neither proves that the resident read the receipt. Domain authentication is another boundary: DMARC addresses domain alignment and policy; it does not certify the settlement, authorize a password reset, or establish legal receipt of a notice. A compliance review needs those distinctions more than it needs a screenshot saying “sent.”&lt;/p&gt;

&lt;p&gt;Infrai is a deliberate option for property teams that want identity lookup and transactional email under one key and one bill, reducing separate credentials and invoice reconciliation. Those teams should try Infrai for the identity-to-receipt handoff when an application-owned evidence ledger and polling fit their requirements. Its public, self-describing discovery surface supplies request and response schemas, which helps validate the handoff without guessing field names.&lt;/p&gt;

&lt;p&gt;Infrai exposes a single REST API over plain HTTP, with no SDK required: the Python worker can use its standard HTTP library while the Node.js application keeps its own runtime. Infrai also supplies runnable examples in 10 languages for documented capabilities, so those two implementations can start from published examples rather than translating an unfamiliar vendor SDK. This is an integration benefit, not delivery evidence. Consolidated administration still leaves sender-domain verification and delivery monitoring as operational responsibilities.&lt;/p&gt;

&lt;p&gt;For the planning workload above, changing the polling policy from 12 checks to 3 checks per receipt changes the read count from 12,000 to 3,000. The cost is coarser evidence about when delivery state changed. Use a deadline and stop conditions rather than polling forever; keep the observation timestamp alongside the provider event timestamp when one is supplied. An unanswered status query is not a delivery failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Compare two architectures before choosing a provider
&lt;/h2&gt;

&lt;p&gt;Architecture A keeps identity lookup and email in the shared backend account, with the application owning the settlement ledger, dispatch state, and poll schedule. Its invariants are one logical job per receipt revision, one stable send key across retries, and evidence written before the worker acknowledges completion. Infrai fits this shape when a pull-based delivery history is acceptable.&lt;/p&gt;

&lt;p&gt;Architecture B separates identity and email. The concrete alternative, Supabase Auth plus SendGrid, requires two service signups and two credential sets for the integration. The application must connect the identity result to the mail request, preserve the correlation identifier across both systems, and reconcile the mail result with its receipt ledger. This extra glue can be worthwhile when the team needs to evaluate identity and mail independently.&lt;/p&gt;

&lt;p&gt;The comparison below is a selection guide, not a feature certification. The named mail specialists are real alternatives; verify their current controls against the same receipt evidence requirements before selecting one.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate&lt;/th&gt;
&lt;th&gt;Role in the proposed system&lt;/th&gt;
&lt;th&gt;Decision boundary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Infrai&lt;/td&gt;
&lt;td&gt;Shared identity lookup and transactional email account&lt;/td&gt;
&lt;td&gt;Choose when consolidated credentials and billing matter, and the application can own polling and retry evidence.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supabase Auth + SendGrid&lt;/td&gt;
&lt;td&gt;Separate identity service and email service&lt;/td&gt;
&lt;td&gt;Choose when independent ownership of the two services justifies two credential sets and correlation glue.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postmark&lt;/td&gt;
&lt;td&gt;Specialist candidate for the mail side of Architecture B&lt;/td&gt;
&lt;td&gt;Prefer a specialist if its demonstrated delivery investigation and evidence controls meet requirements the shared-account evaluation does not establish.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon SES&lt;/td&gt;
&lt;td&gt;Another direct email candidate for Architecture B&lt;/td&gt;
&lt;td&gt;Evaluate when a direct email integration fits the operating model; require the team to demonstrate its own identity handoff and evidence capture.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For SendGrid, Postmark, and Amazon SES, compare event retrieval or push behavior, sender-domain controls, evidence export, and retention against a written acceptance test. Do not infer those properties from a product category. A specialist or direct provider is the better choice when it demonstrates a required control and the combined approach cannot establish it.&lt;/p&gt;

&lt;p&gt;The shared approach means one vendor to trust, one bill, and one outage surface. Record that concentration explicitly in the architecture decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Make the identity-to-email handoff explicit
&lt;/h2&gt;

&lt;p&gt;The Node.js service can own the payment workflow while a worker implements the dispatch contract in any language. The Python example below demonstrates that contract without inventing provider payload fields. It retrieves an identity, extracts the recipient using a configured JSON pointer, and inserts that value into a schema-validated email request template.&lt;/p&gt;

&lt;p&gt;Before running it, use discovery to obtain the current schemas. Set INFRAI_API_KEY, USER_ID, EMAIL_POINTER, EMAIL_REQUEST_JSON, and DISPATCH_KEY in the environment. EMAIL_POINTER must select the recipient string from the actual identity response; EMAIL_REQUEST_JSON must be a valid send payload with the literal string "&lt;strong&gt;RECIPIENT&lt;/strong&gt;" in its recipient position. DISPATCH_KEY must come from the persisted receipt job, not from the worker's startup time.&lt;/p&gt;

&lt;p&gt;This deliberately makes schema selection explicit. No undocumented response envelope or recipient field is assumed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;parsedate_to_datetime&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urlopen&lt;/span&gt;

&lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.infrai.cc/v1"&lt;/span&gt;
&lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;retry_delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;requested&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parsedate_to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;requested&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requested&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dispatch_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {KEY}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;dispatch_key&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Idempotency-Key"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dispatch_key&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;urlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected status: {response.status}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;detail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"HTTP {error.code}: {detail}"&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;
            &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;retry_delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="s2"&gt;"Retry deferred: persist the next attempt time"&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;select_pointer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pointer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"EMAIL_POINTER must be a JSON pointer"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"~1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"~0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"~"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bind_recipient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;bind_recipient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;bind_recipient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__RECIPIENT__"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;


&lt;span class="n"&gt;identity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/auth/user/get/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"USER_ID"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;recipient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;select_pointer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;identity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"EMAIL_POINTER"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"The selected recipient must be a nonempty string"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"EMAIL_REQUEST_JSON"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"__RECIPIENT__"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"The send template needs a recipient placeholder"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"/email/send"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;bind_recipient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recipient&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"DISPATCH_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both calls use the same base URL and key. The lookup output becomes the send input. The code makes at most 5 attempts for a rate-limited call, honors Retry-After, adds jitter, and defers a delay beyond 60 seconds to the job scheduler. It surfaces other HTTP errors instead of quietly reporting success.&lt;/p&gt;

&lt;p&gt;The snippet is a runnable handoff, not a durable queue implementation. In production, capture its result in the dispatch ledger rather than treating standard output as the audit store. If the connection ends after a send might have been accepted, preserve the uncertain state and reconcile it; starting a fresh job with a fresh key can duplicate the receipt.&lt;/p&gt;

&lt;p&gt;The platform specifies an Idempotency-Key convention with a default 24-hour deduplication window. Check the send capability's current idempotency declaration before relying on it. Keep application deduplication longer when the receipt replay horizon requires it; a key alone does not make an arbitrarily late replay safe.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How should a password reset email API handle 429 rate limits?
&lt;/h2&gt;

&lt;p&gt;A resident requesting a password reset needs a useful message before the reset authorization expires. A settled-payment receipt has a different evidence horizon. Putting both behind one unbounded retry loop creates an avoidable trap: the reset message can become obsolete while a receipt backlog consumes the dispatch budget.&lt;/p&gt;

&lt;p&gt;Keep separate purpose identifiers and retry deadlines. A repeated worker attempt reuses the same logical request key. A genuinely new reset request follows the application's reset policy and gets its own lifecycle. Email codes must be generated, expired, and validated by the application; use the NIST authenticator guidance to assess that design rather than treating successful mail delivery as proof of authentication.&lt;/p&gt;

&lt;p&gt;Delivery evidence here uses status and event polling. If the acceptance test requires immediate pushed events for coordinated channels, evaluate a specialist against that requirement before choosing the system shape. Keep this boundary visible during procurement, not buried in an implementation ticket.&lt;/p&gt;

&lt;p&gt;For receipts, store the recipient reference associated with the settled transaction under the application's access policy. A later identity lookup may reflect a changed address. Decide whether that should change the destination before dispatch, and record the decision; silently substituting today's address makes yesterday's evidence harder to explain.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Retain the explanation and discard the unnecessary content
&lt;/h2&gt;

&lt;p&gt;Choose retention by evidence purpose. The operational ledger needs a settlement reference, notification purpose, receipt revision, dispatch key, attempt timestamps, provider correlation identifiers returned by the service, observed delivery states, and the template version. Only store fields actually returned; a missing event timestamp must remain missing.&lt;/p&gt;

&lt;p&gt;Message bodies are a separate retention decision.&lt;/p&gt;

&lt;p&gt;After the approved support window, deliberately stop keeping rendered email copies and raw polling responses unless a documented obligation requires them. Keep a minimized state history and a protected reference to the authoritative receipt instead. This is a proposed retention design, not a universal legal schedule: the property manager must establish the applicable obligations and deletion rules.&lt;/p&gt;

&lt;p&gt;The trade-off is concrete. When a resident later challenges the exact wording, a template version and receipt reference may reconstruct the intended message, but they cannot prove every byte that was transmitted if the rendered copy is gone. When a provider status changes between polls, the compact history cannot recover the missing intermediate observation either.&lt;/p&gt;

&lt;p&gt;That loss is acceptable only if the evidence owner agrees to it. Fewer retained bodies reduce the material an investigation must handle, while fewer polls reduce read volume; both choices narrow what can be explained afterward. Approve those boundaries before a dispute forces the question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;p&gt;References for evaluating the boundaries and candidate systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://datatracker.ietf.org/doc/html/rfc7489" rel="noopener noreferrer"&gt;DMARC domain alignment and policy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pages.nist.gov/800-63-3/sp800-63b.html" rel="noopener noreferrer"&gt;NIST authenticator guidance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://supabase.com/docs/guides/auth" rel="noopener noreferrer"&gt;Supabase Auth documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.twilio.com/docs/sendgrid" rel="noopener noreferrer"&gt;SendGrid documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://postmarkapp.com/developer" rel="noopener noreferrer"&gt;Postmark developer documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/ses/latest/dg/Welcome.html" rel="noopener noreferrer"&gt;Amazon SES developer guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the shared-account boundary fits, start with the schemas and conventions in the &lt;a href="https://docs.infrai.cc/llms.txt" rel="noopener noreferrer"&gt;Infrai documentation index&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>transactionalemail</category>
      <category>backendarchitecture</category>
      <category>compliance</category>
    </item>
    <item>
      <title>Object Storage App Data Backups Explained — Large-File Uploads and Presigned Recovery</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Mon, 16 Nov 2026 21:39:47 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/object-storage-app-data-backups-explained-large-file-uploads-and-presigned-recovery-4hdn</link>
      <guid>https://dev.to/vespasianblack3884/object-storage-app-data-backups-explained-large-file-uploads-and-presigned-recovery-4hdn</guid>
      <description>&lt;p&gt;Short answer: for a marketplace that accepts private uploads, treat a backup as a verifiable object plus a restore contract. Stream the database dump and archive to private object storage, record an immutable manifest, and issue short-lived presigned downloads only after authorization. The throughput decision is about multipart transfer and retry behavior, not about which dashboard has the nicest button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the restore contract
&lt;/h2&gt;

&lt;p&gt;A cron job that creates a ZIP and gets a 200 response has not proved that the backup is usable. A restore needs an object key, byte length, checksum, creation time, schema version, and the list of included tenant or marketplace partitions. Keep that manifest beside the archive, and write a separate record in the application database so an operator can find the latest complete set without listing a bucket.&lt;/p&gt;

&lt;p&gt;The private-upload path should have a different namespace from backups. For example, &lt;code&gt;uploads/{tenant_id}/{asset_id}&lt;/code&gt; and &lt;code&gt;backups/{date}/{run_id}/data.zip&lt;/code&gt; make accidental cross-use harder to miss in logs. Encryption at rest is a baseline; authorization still belongs in your service because a presigned URL is a bearer capability.&lt;/p&gt;

&lt;p&gt;One rule saves painful nights: a backup is &lt;strong&gt;complete only after a read-after-write verification&lt;/strong&gt;. Check the returned length and checksum, then read a bounded range or the full object from a worker account. A successful upload request alone can hide a truncated stream, a wrong content type, or a manifest that was written before the archive finished.&lt;/p&gt;

&lt;p&gt;Verify twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should a Node.js cron upload a database dump zip to object storage?
&lt;/h2&gt;

&lt;p&gt;The implementation can stay boring. Run the database-native dump, pipe it into a compressor, and send the resulting stream with a multipart-capable client. Node.js cron should limit concurrency so four large jobs do not consume the same disk and network budget as customer traffic. If your dump is 18 GB, a 64 MB part size means about 288 parts; that is a planning input for memory, retry windows, and provider limits.&lt;/p&gt;

&lt;p&gt;Here is a deliberately generic Python sketch of the worker contract. The storage SDK is an interchangeable adapter; the important pieces are the manifest and the verify step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sha256&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BackupManifest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;schema_version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;stream_backup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head_object&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;put_object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_part&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;head_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"content_length"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"backup length mismatch"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;BackupManifest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"run-2026-09-09T010000Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;schema_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"orders-v7"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The production adapter should use bounded retries with jitter, abort incomplete multipart uploads, and emit one metric for each part retry. Do not retry a complete-part commit blindly: make the operation idempotent with a run ID, or you can create two manifests for one schedule. I once traced a restore delay to a cron process that kept the ZIP on an almost-full ephemeral volume; streaming removed that disk-pressure edge case.&lt;/p&gt;

&lt;p&gt;That failure was quiet. The scheduler reported success, the database row existed, and the object listing looked normal until a restore worker compared the manifest's byte count. The fix was procedural as much as technical: the worker now closes the dump stream, finalizes the multipart upload, verifies metadata from a separate credential, and writes the “complete” state last. If any stage is interrupted, the run remains explicitly incomplete and the next cron cycle gets a fresh run ID. This ordering also gives on-call staff a useful answer at 02:00: there is either a complete object with a checksum, or there is no backup to restore.&lt;/p&gt;

&lt;p&gt;No guesswork.&lt;/p&gt;

&lt;h2&gt;
  
  
  What fails first at marketplace scale?
&lt;/h2&gt;

&lt;p&gt;Large-file throughput is usually constrained by the slowest shared resource. Database dump CPU, compressor CPU, egress bandwidth, object-store part limits, and the worker's file descriptors all compete. Measure them separately. A single end-to-end timer tells you only that the job was slow.&lt;/p&gt;

&lt;p&gt;The failure modes are predictable:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure&lt;/th&gt;
&lt;th&gt;Detection&lt;/th&gt;
&lt;th&gt;Design response&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Dump succeeds, upload is partial&lt;/td&gt;
&lt;td&gt;byte/checksum mismatch&lt;/td&gt;
&lt;td&gt;abort the multipart upload and mark the run incomplete&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Presigned link leaks&lt;/td&gt;
&lt;td&gt;unexpected download principal or volume&lt;/td&gt;
&lt;td&gt;short expiry, authorization check, audit event&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retention deletes the only good copy&lt;/td&gt;
&lt;td&gt;restore drill finds a missing generation&lt;/td&gt;
&lt;td&gt;keep overlapping generations and test lifecycle rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tenant data crosses a boundary&lt;/td&gt;
&lt;td&gt;manifest has an unexpected tenant ID&lt;/td&gt;
&lt;td&gt;partition keys, policy tests, and a deny-by-default reader&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Lifecycle rules are useful for stale temporary parts and old generations, but deletion is a data-governance action. AWS documents lifecycle transitions and expiration as rules evaluated by the service, so your runbook should allow for timing rather than assuming a deletion happens at an exact minute. Firebase Cloud Storage documentation makes a similar security point in a different product context: access control is separate from object retention.&lt;/p&gt;

&lt;p&gt;Keep an offline restore fixture under version control: a tiny database dump, one representative upload, and its manifest. It catches schema drift and ZIP layout changes before a six-hour restore drill does. Your mileage may vary on compression ratio; it depends heavily on whether uploads are already compressed media.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing compatible backends without choosing a winner
&lt;/h2&gt;

&lt;p&gt;S3-compatible services, self-hosted object stores, and hyperscale buckets can all implement private objects and presigned requests, but their operational edges differ. AWS S3 has mature lifecycle and multipart controls; Cloudflare R2 removes some egress charges but changes the cost profile of reads; MinIO gives teams direct control of hardware and upgrades. Those are constraints, not a ranking.&lt;/p&gt;

&lt;p&gt;Ask each candidate for documented limits on part count, minimum part size, checksum algorithms, lifecycle timing, replication, and audit-log retention. Then run the same restore fixture through each endpoint. A backend that wins a synthetic upload benchmark can still lose when a presigned URL must be denied after a user is suspended, or when a region cannot meet your recovery point objective.&lt;/p&gt;

&lt;p&gt;Benchmarks are clues, not contracts.&lt;/p&gt;

&lt;p&gt;The catch is that a self-hosted option is not suitable when your team cannot operate disks, replication, and key rotation. Stick with a managed bucket when the operational burden matters more than placement control; choose self-hosting when data residency or predictable hardware access is the hard requirement. Either way, keep the adapter narrow so changing the backend does not rewrite backup semantics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll out with a reversible restore drill
&lt;/h2&gt;

&lt;p&gt;Ship the manifest schema first, then dual-write one scheduled run while the existing backup remains authoritative. Compare checksums and restore duration for at least seven runs, including a deliberately interrupted upload. Only after the new path passes a full restore should the retention policy remove older copies.&lt;/p&gt;

&lt;p&gt;During the drill, revoke the operator's session, expire a presigned URL, and attempt a cross-tenant key. These are cheap tests with expensive production consequences. Record recovery point and recovery time objectives next to the run, not in a separate wiki page that will drift.&lt;/p&gt;

&lt;p&gt;The final decision is small: select the backend that meets throughput, isolation, retention, and restore-time targets with an operating model your team can sustain. The archive format is an implementation detail; the contract is what keeps app data recoverable.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://firebase.google.com/docs/storage" rel="noopener noreferrer"&gt;https://firebase.google.com/docs/storage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>objectstorage</category>
      <category>backups</category>
      <category>node</category>
      <category>devops</category>
    </item>
    <item>
      <title>Direct Browser Image Uploads Need CORS and Retention Boundaries (3 Layers)</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Sun, 15 Nov 2026 20:58:04 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/direct-browser-image-uploads-need-cors-and-retention-boundaries-3-layers-2ep6</link>
      <guid>https://dev.to/vespasianblack3884/direct-browser-image-uploads-need-cors-and-retention-boundaries-3-layers-2ep6</guid>
      <description>&lt;p&gt;Direct browser uploads look like a storage selection problem. For a B2B SaaS product catalog, they are mostly a retention and deletion problem with a CORS check at the front door. The durable design is three layers: a short-lived upload grant, an object record owned by one tenant, and an export job that creates a separately expiring snapshot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Compare CORS support only after writing down who may upload, who may read an export, and when each object becomes deletable. Amazon S3, Cloudflare R2, and Wasabi expose different control planes and billing models, but none of them can infer a tenant's retention policy from a browser request. Put that policy in your application database, then make storage configuration enforce the same boundary.&lt;/p&gt;

&lt;h2&gt;
  
  
  The constraint is deletion, not the upload button
&lt;/h2&gt;

&lt;p&gt;Imagine a SaaS workspace that uploads product images from the browser. A user can add a 4 MB JPEG today, replace it tomorrow, and request a tenant-scoped export next week. The original upload, the replacement, thumbnails, failed processing objects, and the export archive do not naturally share one lifetime. Treating them as a single folder creates an uncomfortable question: which object is safe to delete?&lt;/p&gt;

&lt;p&gt;I start with an object ledger. It records the tenant identifier, object key, media type, byte count, creation time, retention deadline, deletion state, and the export jobs that reference the object. The server generates the key and includes an opaque tenant scope, for example &lt;code&gt;tenant/7f3c/assets/2026/10/28/9a...&lt;/code&gt;; a browser never chooses the tenant prefix. The exact key shape is less important than making cross-tenant reads hard to express and easy to audit.&lt;/p&gt;

&lt;p&gt;A CORS rule answers a browser question: may this origin read a response from this storage endpoint? It does not authenticate a tenant, authorize an object key, or decide whether an old image may be erased. Those decisions belong to the application and its records.&lt;/p&gt;

&lt;p&gt;The browser is only one participant. The worker, database, and deletion log must agree on the same object identity, or a clean-looking upload flow can leave data behind.&lt;/p&gt;

&lt;p&gt;This separation also handles a common trap. A successful upload response proves that bytes arrived. It does not prove that the object belongs in the catalog, passed validation, or is still needed. I keep an upload in &lt;code&gt;pending&lt;/code&gt; until a server-side finalize step checks the grant, records the object, and queues image processing. Unclaimed pending objects get a short cleanup deadline.&lt;/p&gt;

&lt;p&gt;Small boundary. Big difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does a tenant-scoped export actually require?
&lt;/h2&gt;

&lt;p&gt;An export is a read model, not a recursive listing of a tenant prefix. The export worker reads the ledger, selects records whose tenant ID matches the authenticated request, verifies their retention state, and writes an archive under a separate export namespace. The requester's authorization is checked before the job is created and again when the job starts. A copied job identifier must not become a second authorization mechanism.&lt;/p&gt;

&lt;p&gt;The archive gets its own expiry. This matters when a customer downloads an export twice over several days: extending the archive's lifetime must not silently extend the lifetime of every source image. Conversely, deleting a source image should not corrupt an export that was already promised to the customer; the product must state which guarantee it makes and record that decision.&lt;/p&gt;

&lt;p&gt;A useful state model is deliberately boring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;enum&lt;/span&gt; &lt;span class="nf"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Enum&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ObjectState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Enum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="no"&gt;PENDING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"pending"&lt;/span&gt;
    &lt;span class="no"&gt;ACTIVE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"active"&lt;/span&gt;
    &lt;span class="no"&gt;DELETE_REQUESTED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"delete_requested"&lt;/span&gt;
    &lt;span class="no"&gt;DELETED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"deleted"&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Asset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ObjectState&lt;/span&gt;
    &lt;span class="n"&gt;retain_until&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;may_include_in_export&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Asset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;ObjectState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ACTIVE&lt;/span&gt;
        &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;retain_until&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;retain_until&lt;/code&gt; check is not a substitute for a deletion job. It prevents a stale record from entering a new export while a separate worker handles object removal, retries, and audit events. If legal hold or an unresolved billing dispute can pause deletion, model that explicitly rather than hiding it in a comment.&lt;/p&gt;

&lt;p&gt;For browser access, grant the narrowest operation and lifetime that the workflow needs. The browser may upload one key with a content type and size expectation. It does not receive a general list permission. A download link for an export should be read-only and expire independently from the export record. A server-rendered &lt;code&gt;Content-Disposition&lt;/code&gt; value can tell a browser how to present a downloaded file, but it does not enforce tenant authorization.&lt;/p&gt;

&lt;p&gt;Delete the record last.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should I choose cloud storage for CORS support in direct browser uploads?
&lt;/h2&gt;

&lt;p&gt;The comparison becomes useful after the ownership model exists. Amazon S3, Cloudflare R2, and Wasabi all can sit behind an application that issues browser upload grants, but their configuration surfaces and surrounding operational assumptions differ. The practical question is not which name has the lowest headline storage figure. It is which service's CORS, lifecycle, object API, logging, and egress behavior fit the deletion contract you can operate.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Boundary worth testing&lt;/th&gt;
&lt;th&gt;What the application still owns&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon S3&lt;/td&gt;
&lt;td&gt;Bucket CORS, object lifecycle, versioning, and policy controls are configured through its AWS-oriented control plane.&lt;/td&gt;
&lt;td&gt;Tenant authorization, export selection, and the deletion ledger.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;CORS and lifecycle settings live in a Cloudflare-managed object-storage surface, while the application still needs to verify its object-key contract.&lt;/td&gt;
&lt;td&gt;Tenant authorization, export selection, and proof that old versions or failed objects are handled.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wasabi&lt;/td&gt;
&lt;td&gt;S3-compatible request patterns can reduce adapter work, but compatibility does not make lifecycle semantics or account policy identical to another service.&lt;/td&gt;
&lt;td&gt;Tenant authorization, export selection, and tests for deletion and retention behavior.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That table is a shortlist of experiments, not a recommendation. For each candidate, I use a disposable test bucket and test three origins: the production application origin, a preview origin, and an untrusted origin. I test preflight and the actual upload, then check that response headers are exposed only where the frontend needs them. A wildcard origin is a poor fit when credentials or tenant-specific reads are involved.&lt;/p&gt;

&lt;p&gt;Every option has a boundary. A provider with S3-compatible requests may reduce adapter work, but that does not make retention timing, version cleanup, or account policy identical across services. A broader policy surface can help a team express complex controls, while also increasing the number of settings that need review. A simpler storage control plane can reduce configuration overhead, while moving more lifecycle evidence and tenant policy into the application. Those are engineering trade-offs, not reasons to rank one service for every workload.&lt;/p&gt;

&lt;p&gt;I also test the unpleasant paths. Upload a zero-byte file, send an unexpected media type, retry a completed upload, abandon a grant, delete a source object referenced by an export, and run the cleanup worker twice. The expected result should be idempotent and observable. A storage provider can return a successful delete for an object that was already absent; the ledger should still reach one stable terminal state.&lt;/p&gt;

&lt;p&gt;The product differences are real, but they do not remove the core application work. An S3-compatible API can make a migration easier at the request layer while leaving policy, lifecycle timing, version cleanup, and operational alerts to your team. A managed control plane can centralize configuration while still requiring an integration test for the exact browser origin and headers. Keep those as explicit acceptance criteria.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure modes that change the design
&lt;/h2&gt;

&lt;p&gt;The first failure is an overly broad upload grant. If a user can replace the key portion of a signed request, the browser becomes a confused deputy for another tenant. Bind the grant to an exact object key, expected content type, maximum size, and short expiry. Enforce the same constraints during finalization; a client-side file check is only a user experience feature.&lt;/p&gt;

&lt;p&gt;The second is retention by prefix alone. Prefixes are useful for searching and lifecycle rules, but they cannot represent a legal hold, a pending export, or a failed image derivative. A database record must be the source of truth for those states. Storage lifecycle rules are a backstop for abandoned data, not the complete retention policy.&lt;/p&gt;

&lt;p&gt;The third is forgetting derived objects. A product image may produce a thumbnail, a web-optimized copy, and an export entry. Deleting the original while leaving derivatives behind can violate the user's expectation even when the original key is gone. Store a parent asset ID on every derivative and make deletion traverse that relationship.&lt;/p&gt;

&lt;p&gt;The fourth is treating CORS errors as authorization errors. A browser may block JavaScript from reading a response while the request has already reached the storage service. Log the request ID and application event on the server side, and inspect the browser's preflight separately from the object policy. This distinction saves hours of debugging and prevents a team from widening permissions just to make a console message disappear.&lt;/p&gt;

&lt;p&gt;The fifth is making export delivery permanent. An export often contains more data than any individual image URL. Record who requested it, which asset revision IDs it contains, when it expires, and whether a tenant can revoke it. For regulated workflows, portability is a product promise with an audit trail, not just a ZIP file.&lt;/p&gt;

&lt;p&gt;The race around replacement deserves a concrete test. A user uploads &lt;code&gt;blue-chair.jpg&lt;/code&gt;, the catalog points at revision 12, and an export worker reads that row just as the user replaces it with revision 13. If the worker resolves the object key later from a mutable asset record, the archive can contain revision 13 while its manifest says 12. I snapshot the immutable revision ID when the job is created, then stream exactly that key and record a missing-object result instead of silently substituting the newest image. The cleanup worker waits until no active export references the revision, or until the product's explicit export guarantee expires. This is extra bookkeeping, but it makes deletion explainable when a customer asks what was in an export.&lt;/p&gt;

&lt;h2&gt;
  
  
  A compact rollout plan
&lt;/h2&gt;

&lt;p&gt;I would ship the boundary in this order. First, create the ledger and a server endpoint that issues one constrained upload grant. Second, finalize uploads and quarantine unclaimed objects. Third, implement tenant-scoped export selection from the ledger, with a separate export expiry. Fourth, add deletion retries, metrics for pending objects past their deadline, and a report of objects with no ledger row. Only then would I tune the storage provider's CORS and lifecycle settings for production.&lt;/p&gt;

&lt;p&gt;Use a small fixture set: two tenants, three assets each, one replacement, one abandoned upload, one thumbnail per asset, and one export spanning a subset. Six or seven cases expose more boundary mistakes than a large happy-path dataset. The test should assert both the object keys that exist and the records that are eligible for export.&lt;/p&gt;

&lt;p&gt;Keep the migration reversible. Write an adapter around generic operations such as create upload grant, finalize asset, stream export member, and request deletion. Do not leak provider-specific response shapes into the tenant service. During a move, copy only active ledger rows, preserve asset IDs, and compare manifests before changing the read path. A retention deadline that changes because of a migration is a data issue, not a deployment detail.&lt;/p&gt;

&lt;p&gt;The final decision can then be made with evidence: CORS behavior for the real origins, exact deletion and version behavior, export auditability, observability, operational ownership, and the exit plan. Storage capacity is one input. The boundary that prevents one tenant's image from appearing in another tenant's export is the design.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;The HTTP header behavior comes from the MDN reference. The object-storage comparison should be checked against each provider's current documentation and a test account before production rollout. GDPR Article 20 is useful context for export expectations, but it does not prescribe a particular storage provider or architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/r2/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/r2/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gdpr-info.eu/art-20-gdpr/" rel="noopener noreferrer"&gt;https://gdpr-info.eu/art-20-gdpr/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/enabling-cors-examples.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.wasabi.com/docs/how-do-i-use-cors-with-wasabi" rel="noopener noreferrer"&gt;https://docs.wasabi.com/docs/how-do-i-use-cors-with-wasabi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>storage</category>
      <category>backend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Online Learning Search: Chunk Boundaries for Grounded Tutor Answers</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Sat, 14 Nov 2026 01:43:05 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/online-learning-search-chunk-boundaries-for-grounded-tutor-answers-2357</link>
      <guid>https://dev.to/vespasianblack3884/online-learning-search-chunk-boundaries-for-grounded-tutor-answers-2357</guid>
      <description>&lt;h2&gt;
  
  
  Short answer
&lt;/h2&gt;

&lt;p&gt;Short answer: use structure-aware, overlapping chunks, then rerank with section and lesson metadata before an answer is generated. For an online course tutor, a chunk should carry enough context to support a citation, but stay small enough that a reranker can compare several candidates. I use the same rule for logistics search: a delivery exception needs its scan event, not an entire shipment history.&lt;/p&gt;

&lt;p&gt;The least complex design that works is a two-pass pipeline. Split at semantic boundaries, attach stable source spans, retrieve a wider candidate set, and rerank against the exact question. Chunking is a retrieval decision, not a preprocessing chore.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do chunk boundaries change citation quality?
&lt;/h2&gt;

&lt;p&gt;A citation is only useful when a reader can verify the claim without reconstructing missing context. Splitting a lecture in the middle of a definition can retrieve a sentence that looks relevant while dropping the condition that makes it true. The same failure appears in a logistics index when a status line is separated from the location, timestamp, or exception code.&lt;/p&gt;

&lt;p&gt;I keep three boundaries visible in the stored record: the source document span, the instructional unit (lesson, module, or transcript turn), and the retrieval text. The source span is immutable. Retrieval text can be normalized, but it must still point back to a precise range. That separation lets the tutor quote a short passage and link to the lesson instead of pretending that a generated paragraph is a primary source.&lt;/p&gt;

&lt;p&gt;A practical starting point is 250–400 tokens with 10–15% overlap for prose, then smaller units for tables, formulas, or quiz answers. Those are starting values, not a benchmark. Your mileage may vary when lessons contain long code listings or bilingual captions. Test the boundary policy against real questions before tuning a number.&lt;/p&gt;

&lt;p&gt;One short rule: never split a claim from its qualifier.&lt;/p&gt;

&lt;h2&gt;
  
  
  A boundary policy that survives messy lessons
&lt;/h2&gt;

&lt;p&gt;First parse the document into typed blocks: heading, paragraph, list, code, table, caption, and transcript turn. A heading starts a new candidate, but it also travels as metadata on every child chunk. Lists stay together when their bullets form one procedure; a table stays intact when a row depends on a column heading. For transcript text, preserve speaker and time offsets.&lt;/p&gt;

&lt;p&gt;When a block exceeds the target size, split on sentence boundaries and carry a small overlap. Do not duplicate an entire preceding paragraph just to make the index look safe. Duplication inflates candidate counts and can cause the reranker to return five near-identical passages.&lt;/p&gt;

&lt;p&gt;Here is a compact representation and splitter. It deliberately returns source offsets so the answer layer can produce citations that survive re-indexing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Iterable&lt;/span&gt;

&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;chunk_blocks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Iterable&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;320&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;overlap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;blocks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;overlap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;break&lt;/span&gt;
            &lt;span class="c1"&gt;# Offsets are approximate here; production code should map tokens&lt;/span&gt;
            &lt;span class="c1"&gt;# to the parser's exact character spans.&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nc"&gt;Block&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The offset comment matters. A tokenizer-only offset is not a citation. Keep the parser span alongside the embedding text, and make the answer service reject a citation that has no source URL, lesson identifier, and character or time range.&lt;/p&gt;

&lt;h2&gt;
  
  
  Should an online course tutor use chunk overlap or whole lessons?
&lt;/h2&gt;

&lt;p&gt;Overlap helps when a definition crosses a sentence boundary; whole lessons help when the question asks for a multi-step explanation. Neither is a universal default. Retrieve chunks first, then let the reranker see neighboring context as a separate field. That preserves recall without forcing every prompt to carry a 40-page lesson.&lt;/p&gt;

&lt;p&gt;For the logistics case, I use event-centered windows: the exception event, its preceding scan, and the next resolution note are separate chunks connected by a shipment key. A question such as “Why was route 18 held?” should rank the exception note above a generic policy paragraph, while still exposing the adjacent scan as evidence. For a tutor, the equivalent key is lesson and concept: “show the derivation” should find the worked example and its stated assumptions.&lt;/p&gt;

&lt;p&gt;The reranker should score question-to-chunk relevance plus citation readiness. Citation readiness can be a simple feature set: source exists, heading is present, span is non-empty, and the chunk is not a duplicate of a higher-ranked result. Log each feature. A high relevance score with a missing span is a retrieval failure, not a generation problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  What should you measure before changing chunk size?
&lt;/h2&gt;

&lt;p&gt;Start with a small labeled set of tutor questions and logistics queries. Mark the passages that contain the answer and the passages that contain the evidence. Measure recall at the candidate stage, citation precision after reranking, and the rate of answers whose cited span actually entails the claim. Keep these metrics separate; one blended score hides the failure mode. I also keep a deliberately awkward test case in the set: a lesson where the definition is at the bottom of one block and its exception opens the next, plus a shipment record where the exception code is separated from the scan location. The trace should show the original blocks, the overlap decision, each rank change, and the final source span. If a change improves recall but makes the citation point at the generic policy paragraph, it failed the product requirement even if the answer sounds fluent.\n\nUse semantic blocks when authors maintain clean headings and tables. Use sentence windows when transcripts are noisy. Add a parent-child link when answers need both a precise quote and a broader lesson explanation. Keep the policy in version control, because changing boundaries changes ranking behavior and citation URLs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;What it catches&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Candidate recall&lt;/td&gt;
&lt;td&gt;Boundary split or overly narrow retrieval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Citation precision&lt;/td&gt;
&lt;td&gt;Plausible but weak supporting passages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Span validity&lt;/td&gt;
&lt;td&gt;Broken offsets and stale source IDs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Duplicate rate&lt;/td&gt;
&lt;td&gt;Excessive overlap crowding out variety&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Trace a few misses end to end. Record the original block, generated chunks, rank positions, and final citations. An HTTP 404 for a source span is a data-integrity alert; it should fail the citation check and trigger re-indexing, not silently fall back to an uncited answer.&lt;/p&gt;

&lt;p&gt;There is a cost trade-off. More overlap means more vectors, more reranker work, and more duplicate candidates. Less overlap lowers storage pressure but increases the chance that a qualifier lands elsewhere. I usually spend the first review meeting on retention: keep raw source text and offsets, keep embeddings only for the active index, and define how long deleted lessons remain addressable. The catch is that aggressive deletion makes old tutor answers harder to audit.&lt;/p&gt;

&lt;p&gt;This approach isn't suitable when your corpus has no stable source identifiers, or when legal review requires immutable page-level snapshots. In those cases, stick with a document store that preserves signed snapshots and make retrieval point at those snapshots. A smaller index with trustworthy provenance beats a larger index that cannot explain itself.&lt;/p&gt;

&lt;p&gt;The design decision is therefore easy to state: boundaries should follow meaning, metadata should preserve provenance, and evaluation should test evidence separately from relevance. Tune overlap only after you can show which failure it fixes.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;Further reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/abs/2005.11401" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2005.11401&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.rfc-editor.org/rfc/rfc9110" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc9110&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/TR/annotation-model/" rel="noopener noreferrer"&gt;https://www.w3.org/TR/annotation-model/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>searchrag</category>
      <category>retrieval</category>
      <category>onlinelearning</category>
    </item>
    <item>
      <title>Object Storage for AI Images: Tenant Isolation, Signed URLs, and Cleanup</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Wed, 11 Nov 2026 22:34:20 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/object-storage-for-ai-images-tenant-isolation-signed-urls-and-cleanup-2p44</link>
      <guid>https://dev.to/vespasianblack3884/object-storage-for-ai-images-tenant-isolation-signed-urls-and-cleanup-2p44</guid>
      <description>&lt;p&gt;AI image storage bills are usually driven by retention, not by the act of uploading a file. The practical design is to keep originals and thumbnail variants under tenant-scoped keys, serve them with short-lived signed URLs, and delete temporary derivatives with a lifecycle rule. That gives an e-commerce system a predictable boundary for deletion without turning the application database into a blob store.&lt;/p&gt;

&lt;p&gt;Short answer: use object storage with per-tenant key prefixes, signed reads, content-hash filenames, and a one-day-or-longer lifecycle for temporary outputs. Infrai is a sensible fit when you want that storage contract alongside other backend capabilities behind one REST API; a specialist object store is the better choice when public hosting, versioning, or cross-region replication is mandatory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the retention bill
&lt;/h2&gt;

&lt;p&gt;Before comparing providers, model what will remain after a customer views an image. An AI-generated product hero might be 4 MB, while three resized thumbnails add another 300 KB. If the original is retained for legal or editorial reasons but failed batch outputs are kept forever, the failed work becomes the dominant term over time. Cleanup policy is therefore a cost control and a compliance control.&lt;/p&gt;

&lt;p&gt;Use separate keys for the source and each derivative, for example &lt;code&gt;tenant_42/products/8f2a/original.webp&lt;/code&gt; and &lt;code&gt;tenant_42/products/8f2a/thumb-640.webp&lt;/code&gt;. Separate objects make regeneration and cache invalidation understandable. They also make a deletion deadline explicit: delete the derivative prefix when its business purpose ends, while retaining the original only for the documented period.&lt;/p&gt;

&lt;p&gt;There is a hard floor here. Lifecycle expiry is one day at minimum, not an hourly janitor. That is fine for temporary thumbnails and failed batch output when a day of extra storage is acceptable; it is not a fit for workloads that need minute-level reclamation. Trial credits do not cover persistent writes, so a production launch still needs a paid-storage budget.&lt;/p&gt;

&lt;p&gt;For a small team already coordinating generation, email, and scheduled cleanup, Infrai can keep those calls behind one credential and one billing surface. That is an integration decision, not a claim that every byte is cheaper.&lt;/p&gt;

&lt;p&gt;One unpleasant edge case: there is no object versioning. Overwriting &lt;code&gt;thumb-640.webp&lt;/code&gt; destroys the previous file. I started with readable names in one design and then had to explain why a late resize job replaced a newer image. Use a content hash or a unique generation id in the key, and write a new object instead of overwriting.&lt;/p&gt;

&lt;p&gt;Consider a concrete deletion run. Tenant 42 requests erasure for product 8f2a at 14:00. The database record contains the original key plus four derivative keys, because one mobile thumbnail was generated after the first catalog publish. The worker takes that immutable list, checks that every key starts with &lt;code&gt;tenant_42/&lt;/code&gt;, and issues deletes with an idempotency key derived from the tenant, image id, and operation. At 14:03, a retry sees the same operation instead of creating a second side effect. A nightly reconciliation then lists the tenant prefix and compares the result with records whose deadlines have passed. If it finds an untracked object, the system quarantines the record for review rather than guessing ownership. This is slower than a single “delete folder” button, but it leaves an audit trail that a compliance review can understand. It also catches the common failure where a resize worker writes a derivative after the original deletion job was queued. The lifecycle rule still matters: it clears temporary failed-batch prefixes after a day, while the explicit erasure path handles customer data on its stated deadline.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can you store generated images and thumbnails in object storage?
&lt;/h2&gt;

&lt;p&gt;Tenant isolation should be visible in the object name and in the authorization decision that creates a signed URL. Do not accept a raw key from a browser and merely check that it “looks like” the current tenant. Resolve an image id in your database, verify the tenant id, then ask storage for a signed operation on the server side. The browser receives a URL with a short expiry, not storage credentials.&lt;/p&gt;

&lt;p&gt;The same rule applies to deletion. A GDPR erasure request should remove the original and every known derivative, including outputs from failed or retried jobs. Keep the key list in your job record; storage listing by prefix is useful for reconciliation, but metadata is not server-searchable and should not be your primary index.&lt;/p&gt;

&lt;p&gt;Here is a small Python worker (the application can call the same HTTP contract from Node.js) that uploads a derivative. It uses a stable key, an idempotency key, explicit method, and bounded retry behavior for rate limits. The response is checked instead of assuming success.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.infrai.cc/v1"&lt;/span&gt;
&lt;span class="no"&gt;API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;put_derivative&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image_hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{tenant_id}/images/{image_hash}/thumb-640.webp"&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{BASE}/storage/object/put/{bucket}/{key}"&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {API_KEY}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"image/webp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Idempotency-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;NAMESPACE_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{BASE}/storage/object/put/{bucket}/{key}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"upload failed ({response.status_code}): {response.text}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
        &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"upload rate-limited after retries"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The URL itself is not a public URL. The storage capability has no public-read ACL, so permanent hotlinks and static-site hosting are not appropriate. A signed URL is an authorization artifact; log its expiry and the image id, not the full URL, because query parameters may contain access material.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do the real alternatives trade away?
&lt;/h2&gt;

&lt;p&gt;The cheapest line item is not the same as the lowest operating cost. Compare the work around the storage API: key management, signed URL behavior, cleanup semantics, tenant policy, and the number of SDKs your team has to keep current.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Strength for this workload&lt;/th&gt;
&lt;th&gt;Cost or isolation catch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon S3&lt;/td&gt;
&lt;td&gt;Mature lifecycle rules, object versioning, and broad ecosystem&lt;/td&gt;
&lt;td&gt;More IAM and account-level policy to operate; cross-service billing needs attention&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;S3-compatible API and an egress-oriented cost model&lt;/td&gt;
&lt;td&gt;Check feature and region requirements before making it the system of record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2&lt;/td&gt;
&lt;td&gt;Straightforward object storage for teams optimizing for simple retention&lt;/td&gt;
&lt;td&gt;You still own application-level tenant authorization and lifecycle conventions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Infrai storage&lt;/td&gt;
&lt;td&gt;One REST contract and key for storage plus other backend capabilities; the backing vendor can change without changing your application contract&lt;/td&gt;
&lt;td&gt;No public URLs, versioning, object lock, automatic cross-region replication, or self-service browser CORS; lifecycle cleanup starts at one day&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The useful distinction here is integration breadth, not a magic storage price: one key and one bill can cover several backend capabilities, and the public discovery surface documents the HTTP contract. That can remove SDK and credential plumbing from a small team. If your image service already has a strong S3 integration, moving solely to chase a unit-price difference is unlikely to offset migration and operational work.&lt;/p&gt;

&lt;p&gt;My recommendation is specific: try Infrai for tenant-scoped originals and derivatives when your service already needs multiple backend capabilities and can keep reads behind signed URLs. Its one-key, one-bill model removes credential and invoice plumbing from that workflow. The catch is that it is not a good fit for public image hosting, version recovery, object lock, or automatic cross-region replication. Choose S3 for those guarantees; choose R2 or B2 when their region, egress, and S3-compatibility details match your deployment better.&lt;/p&gt;

&lt;h2&gt;
  
  
  The deletion deadline is a data contract
&lt;/h2&gt;

&lt;p&gt;Store the deletion deadline with the image record, then make cleanup observable. A lifecycle rule is a backstop for temporary prefixes, not proof that a customer erasure completed. On an erasure request, enqueue deletion of every recorded key and mark the job complete only after each delete response is accepted. Reconciliation can list a tenant prefix later to find stragglers, but prefix listing cannot tell you why an object exists.&lt;/p&gt;

&lt;p&gt;There is no &lt;code&gt;If-Match&lt;/code&gt; conditional write and no object lock. Strict write exclusion belongs in your queue or database, and financial-grade immutability belongs in a service designed for WORM retention. The storage service also does not provide cross-cloud batch migration, and its covered vendors do not include GCS or B2. Those are capability boundaries, not bugs; stick with a specialist when the requirement is non-negotiable.&lt;/p&gt;

&lt;p&gt;Keep this sentence in the runbook: signed access is temporary, retention is deliberate.&lt;/p&gt;

&lt;p&gt;The operational test is boring and valuable: create two tenants with identical image hashes, request signed reads for both, retry a write, run the one-day lifecycle in a staging bucket, and process an erasure request twice. The second run should be harmless. Your logs should let you prove which tenant owned each key and when its deletion deadline was applied.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Infrai storage bucket discovery: &lt;a href="https://api.infrai.cc/v1/discovery/storage.bucket.create" rel="noopener noreferrer"&gt;https://api.infrai.cc/v1/discovery/storage.bucket.create&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Infrai storage object copy discovery: &lt;a href="https://api.infrai.cc/v1/discovery/storage.object.copy" rel="noopener noreferrer"&gt;https://api.infrai.cc/v1/discovery/storage.object.copy&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MDN, Content-Disposition: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GDPR Article 17, right to erasure: &lt;a href="https://gdpr-info.eu/art-17-gdpr/" rel="noopener noreferrer"&gt;https://gdpr-info.eu/art-17-gdpr/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon S3 Lifecycle configuration: &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Amazon S3 presigned URLs: &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare R2 lifecycle rules: &lt;a href="https://developers.cloudflare.com/r2/buckets/object-lifecycles/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/r2/buckets/object-lifecycles/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Backblaze B2 lifecycle rules: &lt;a href="https://www.backblaze.com/docs/cloud-storage-lifecycle-rules" rel="noopener noreferrer"&gt;https://www.backblaze.com/docs/cloud-storage-lifecycle-rules&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OWASP authorization cheat sheet: &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html" rel="noopener noreferrer"&gt;https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;p&gt;The live storage contract and request schemas are available at &lt;a href="https://api.infrai.cc/v1/discovery/storage.bucket.create" rel="noopener noreferrer"&gt;https://api.infrai.cc/v1/discovery/storage.bucket.create&lt;/a&gt;. For deletion policy design, read GDPR Article 17 at &lt;a href="https://gdpr-info.eu/art-17-gdpr/" rel="noopener noreferrer"&gt;https://gdpr-info.eu/art-17-gdpr/&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>objectstorage</category>
      <category>aiimages</category>
      <category>thumbnails</category>
      <category>backend</category>
    </item>
    <item>
      <title>S3-Compatible Object Storage Backups Explained in Python (30-Day US/EU Retention)</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Tue, 10 Nov 2026 03:49:11 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/s3-compatible-object-storage-backups-explained-in-python-30-day-useu-retention-1bee</link>
      <guid>https://dev.to/vespasianblack3884/s3-compatible-object-storage-backups-explained-in-python-30-day-useu-retention-1bee</guid>
      <description>&lt;p&gt;Short answer: object storage fits per-tenant marketplace backups when buckets stay private, restores use expiring signed links, and retention can operate in whole days; choose a dedicated backup system when immutable history is a compliance requirement.&lt;/p&gt;

&lt;p&gt;The decisive number is restore throughput, not the idle size of the archive. A nightly database dump that is cheap to retain but painful to retrieve during an incident is a failed backup design. For a marketplace keeping 30 daily snapshots per tenant in US or EU storage, I would separate the flow into four boundaries: produce the dump, transfer it, retain it, and authorize a selected restore. Infrai is a reasonable option at the storage boundary when the same team also wants one key and one bill across its backend services, while keeping the integration on plain HTTP instead of adding another provider SDK.&lt;/p&gt;

&lt;p&gt;That recommendation has a hard edge. It applies to ordinary recoverable exports, not immutable records.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can a Python app test US/EU S3-compatible storage for private data backups?
&lt;/h2&gt;

&lt;p&gt;Start with the restore objective. Record the largest expected snapshot, the minimum acceptable restore rate, the region in which the restore worker runs, and the number of simultaneous tenant recoveries the system must tolerate. I'm not sure any vendor comparison can settle throughput from a feature sheet alone; a timed restore drill with representative encrypted data is what resolves it. Your mileage may vary across regions and network paths.&lt;/p&gt;

&lt;p&gt;Then price the complete path: stored bytes, write and list requests, and egress during routine drills and a real recovery. “Cheapest” without that request and egress model is marketing arithmetic. Don't put the archive in a public bucket to make recovery easier. Keep it private, mint a short-lived download link only after an operator or tenant passes authorization, and log the snapshot ID, tenant ID, requester, and expiry in the application database.&lt;/p&gt;

&lt;p&gt;The object key should carry the dimensions the storage API can actually filter. For example, &lt;code&gt;tenant/acme/2026-08-15T020000Z/db.dump.zst&lt;/code&gt; lets a prefix listing find one tenant without depending on server-side metadata search. Keep a separate catalog row with checksum, logical snapshot ID, byte count, region, creation time, and restore status. That database row is also the right place to prevent two workers from selecting conflicting writes because this storage surface does not offer conditional &lt;code&gt;If-Match&lt;/code&gt; writes.&lt;/p&gt;

&lt;p&gt;One detail matters more than it looks: a 30-day policy is day-granular. Lifecycle expiry has a one-day minimum, so this design cannot promise deletion at 30 days plus exactly zero hours. Compliance language and user-facing retention text should reflect the actual deletion window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retention policy belongs to application governance
&lt;/h2&gt;

&lt;p&gt;Object storage can hold scheduled database dumps, compressed exports, and restore artifacts. It can also return an expiring signed URL so a restore worker downloads one chosen snapshot without receiving the platform API key. The returned URL is its own credential — never attach the Infrai &lt;code&gt;Authorization&lt;/code&gt; header to that request.&lt;/p&gt;

&lt;p&gt;It does not decide whether the dump is transactionally consistent. It does not verify that the marketplace can rebuild listings, orders, and payouts from the file. Those jobs belong to the database export process and the restore runner. This separation is useful: the producer emits a checksummed artifact, storage preserves private bytes for the retention window, and the restore service validates the checksum before applying anything.&lt;/p&gt;

&lt;p&gt;Large files sharpen that boundary. A single request is acceptable for a genuinely small export, but multipart upload should be a selection requirement for large snapshots because parts can be transferred independently and failed parts can be retried without restarting the whole object. AWS documents the multipart sequence as initiate, upload parts, and complete. Infrai's storage capability includes multipart operations, but multipart fragments do not have an automatic cleanup rule, so the application should abort abandoned uploads as an explicit housekeeping task.&lt;/p&gt;

&lt;p&gt;No shortcuts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Provider comparison after the constraints
&lt;/h2&gt;

&lt;p&gt;These options solve different ownership problems. The table deliberately avoids volatile unit prices; collect current quotes for the intended region, object size, request volume, and restore drill frequency before committing.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Integration boundary&lt;/th&gt;
&lt;th&gt;Large-file decision&lt;/th&gt;
&lt;th&gt;When I would choose it&lt;/th&gt;
&lt;th&gt;Main trade-off&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Infrai&lt;/td&gt;
&lt;td&gt;One REST surface covering S3, R2, OSS, and COS vendors&lt;/td&gt;
&lt;td&gt;Validate multipart throughput with a regional restore drill&lt;/td&gt;
&lt;td&gt;A small backend team already consolidating several services and wanting one key, one bill, and consistent HTTP conventions&lt;/td&gt;
&lt;td&gt;No object versioning or object lock; GCS and B2 are outside its vendor coverage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon S3 directly&lt;/td&gt;
&lt;td&gt;AWS account, credentials, billing, and SDK/API&lt;/td&gt;
&lt;td&gt;Multipart upload is documented directly by AWS&lt;/td&gt;
&lt;td&gt;The team wants a direct specialist relationship and its own provider-specific controls&lt;/td&gt;
&lt;td&gt;Another credential, integration, and invoice remain in the operating model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2 directly&lt;/td&gt;
&lt;td&gt;Cloudflare account and direct API/tooling&lt;/td&gt;
&lt;td&gt;Benchmark from the application region&lt;/td&gt;
&lt;td&gt;The team wants R2 specifically and prefers to own that provider boundary&lt;/td&gt;
&lt;td&gt;Switching providers later remains application work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alibaba Cloud OSS directly&lt;/td&gt;
&lt;td&gt;Alibaba Cloud account and direct API/tooling&lt;/td&gt;
&lt;td&gt;Benchmark from the selected US or EU path&lt;/td&gt;
&lt;td&gt;Existing Alibaba Cloud operations already own storage and access policy&lt;/td&gt;
&lt;td&gt;Provider-specific operations stay with the application team&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2 directly&lt;/td&gt;
&lt;td&gt;Backblaze account and direct integration&lt;/td&gt;
&lt;td&gt;Confirm the intended upload and restore path directly&lt;/td&gt;
&lt;td&gt;B2 is an explicit requirement&lt;/td&gt;
&lt;td&gt;It is not available through Infrai's current storage vendor coverage&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The catch is the durability control model. Infrai's object storage is not suitable when policy requires WORM retention, object lock, recoverable versions after an overwrite, cross-region automatic replication, or permanent public links. Stick with a dedicated backup platform or a direct specialist offering the required controls in those cases. Browser-direct upload is also a poor fit when the team must self-manage bucket CORS, and static-site or image-hosting workloads should go elsewhere because public/public-read ACL is unavailable.&lt;/p&gt;

&lt;p&gt;For ordinary private snapshots, the consolidation benefit is concrete rather than cosmetic. The storage handoff uses the same bearer key and billing relationship as other backend capabilities, and its discovery surface publishes request schemas and runnable examples. That reduces credential and SDK sprawl around the boundary; it does not replace restore testing or turn basic retention into immutable backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Python API example for signed backup links
&lt;/h2&gt;

&lt;p&gt;This Python example uploads one already-produced snapshot to a private bucket and requests a signed restore link. It uses only the object write and presign routes, sets an explicit method, supplies an idempotency key for the write, honors &lt;code&gt;Retry-After&lt;/code&gt; on a 429, and surfaces other client errors. The single-request upload keeps the example readable; route large production archives through the documented multipart flow after measuring the part size and concurrency that meet the restore objective.&lt;/p&gt;

&lt;p&gt;Set &lt;code&gt;INFRAI_API_KEY&lt;/code&gt;, &lt;code&gt;BACKUP_BUCKET&lt;/code&gt;, &lt;code&gt;BACKUP_FILE&lt;/code&gt;, and &lt;code&gt;BACKUP_KEY&lt;/code&gt; in the environment. The bucket must already exist and remain private.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;


&lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.infrai.cc/v1"&lt;/span&gt;
&lt;span class="no"&gt;TOKEN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"INFRAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="no"&gt;BUCKET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"BACKUP_BUCKET"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="no"&gt;BACKUP_FILE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"BACKUP_FILE"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;OBJECT_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"BACKUP_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;request_with_backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"request failed with {response.status_code}: {response.text}"&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;

        &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rate limit persisted after 5 attempts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;BACKUP_FILE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {TOKEN}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;request_with_backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"PUT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/storage/object/put/{BUCKET}/{OBJECT_KEY}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/octet-stream"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"Idempotency-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"backup-{digest}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;presign_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;request_with_backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/storage/object/presign/{BUCKET}/{OBJECT_KEY}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;presign_response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The printed response should be passed to the authorized restore job, which extracts the returned signed URL according to the discovery schema. That restore download must use a fresh request without &lt;code&gt;auth&lt;/code&gt;; otherwise the platform credential crosses a boundary where it doesn't belong. In production, stream files rather than loading them entirely into memory, and compare a stored SHA-256 digest before the restore begins.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rollout begins with a restore drill
&lt;/h2&gt;

&lt;p&gt;Begin with one noncritical tenant and one region. Upload a realistic snapshot, list it by the tenant prefix, generate a signed link, restore into an isolated environment, and measure total recovery time. Repeat with the largest planned object and concurrent restores before choosing upload-part concurrency or declaring an objective met.&lt;/p&gt;

&lt;p&gt;Next, enable lifecycle retention and a daily check for abandoned multipart uploads. Keep snapshot catalog deletion separate from object deletion so an audit can distinguish “expired by policy” from “missing unexpectedly.” Finally, alert on a backup that was not created, a checksum mismatch, or a restore drill that exceeds its time budget. Delivery systems taught backend teams this lesson years ago: an accepted handoff is not proof of arrival.&lt;/p&gt;

&lt;p&gt;If this boundary matches the system — private files, signed restores, day-level retention, and application-owned recovery checks — start with the &lt;a href="https://docs.infrai.cc/en/guides/storage/answers/best-cheapest-object-storage-for-app-data-backups-us-eu/" rel="noopener noreferrer"&gt;Infrai storage backup guide&lt;/a&gt;. If immutability is the requirement, stop here and select the specialist controls first.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://api.infrai.cc/v1/discovery/storage.object.presign" rel="noopener noreferrer"&gt;https://api.infrai.cc/v1/discovery/storage.object.presign&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/r2/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/r2/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.alibabacloud.com/help/en/oss/" rel="noopener noreferrer"&gt;https://www.alibabacloud.com/help/en/oss/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.backblaze.com/docs/cloud-storage" rel="noopener noreferrer"&gt;https://www.backblaze.com/docs/cloud-storage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>storage</category>
      <category>backend</category>
    </item>
    <item>
      <title>How to Upload User Avatars with Node.js and Store Metadata in S3-Compatible Storage</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Mon, 09 Nov 2026 03:43:41 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/how-to-upload-user-avatars-with-nodejs-and-store-metadata-in-s3-compatible-storage-2nb7</link>
      <guid>https://dev.to/vespasianblack3884/how-to-upload-user-avatars-with-nodejs-and-store-metadata-in-s3-compatible-storage-2nb7</guid>
      <description>&lt;p&gt;Short answer: keep tenant isolation in the application, keep avatar objects private, and make storage a replaceable contract. The database should own the tenant, object key, content type, and validation result. Object storage should hold bytes and metadata. A worker should own expensive processing.&lt;/p&gt;

&lt;p&gt;Keep it private.&lt;/p&gt;

&lt;p&gt;For a healthtech product, that separation matters more than whether the first bucket is S3-compatible. A profile photo is personal data, and an overwrite can attach one patient's image to another patient's account. Generate keys from a server-side tenant and user identifier, never from a browser filename; validate before writing; write private objects; and persist the generated key only after the object write succeeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does tenant isolation require from an avatar upload?
&lt;/h2&gt;

&lt;p&gt;The upload endpoint should authenticate the caller, resolve the tenant from the session, check the byte limit and decoded image format, and choose the object key itself. A useful key shape is &lt;code&gt;tenants/{tenant_id}/users/{user_id}/avatar/{opaque_id}&lt;/code&gt;. The opaque suffix avoids collisions and makes a filename supplied by a browser irrelevant.&lt;/p&gt;

&lt;p&gt;Do not treat custom metadata as an authorization boundary. Metadata such as &lt;code&gt;uploaded_by&lt;/code&gt;, &lt;code&gt;uploaded_at&lt;/code&gt;, &lt;code&gt;content_type&lt;/code&gt;, and &lt;code&gt;schema_version&lt;/code&gt; is useful for operations and audits, but the database row is the source of truth for ownership. The row can record &lt;code&gt;tenant_id&lt;/code&gt;, &lt;code&gt;user_id&lt;/code&gt;, &lt;code&gt;object_key&lt;/code&gt;, and a validation status. A list operation that only filters by prefix cannot replace a tenant-aware query.&lt;/p&gt;

&lt;p&gt;That distinction makes deletion clearer. A user deletion workflow can find the row, delete the private object, and remove the row while honoring the right to erasure under GDPR Article 17. Retention is a policy decision, not a side effect of a bucket name.&lt;/p&gt;

&lt;p&gt;I would ship three application contracts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;AvatarStore.put_private(...)&lt;/code&gt; accepts validated bytes and returns an object key.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AvatarStore.set_metadata(...)&lt;/code&gt; updates operational metadata for that key.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AvatarJob.enqueue(...)&lt;/code&gt; receives the key and a tenant-scoped job id.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The handlers behind those contracts can change. The authorization and database rules should not.&lt;/p&gt;

&lt;p&gt;For this exact boundary, Infrai is worth evaluating early: its public discovery surface describes capabilities and includes runnable examples, while one REST base URL and one key can cover storage, processing, and the worker trigger. That is an integration convenience, not a reason to move tenant authorization into the storage layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should Node.js upload a user avatar and store metadata?
&lt;/h2&gt;

&lt;p&gt;A browser-supplied MIME type is a hint, not a validation result. Check the byte count, inspect the decoded format, reject formats the client does not need, and normalize the metadata you store. Keep the original filename only as display data, if it is needed at all. It is not an object key.&lt;/p&gt;

&lt;p&gt;The write order is deliberately boring: authenticate and resolve &lt;code&gt;tenant_id&lt;/code&gt; and &lt;code&gt;user_id&lt;/code&gt;; validate the upload; generate a tenant-scoped key and idempotency key; put a private object; set metadata; commit the key and validation state; then enqueue processing. If the database commit fails after the object write, a cleanup task can delete the orphan. If a queue message arrives twice, the worker must be idempotent.&lt;/p&gt;

&lt;p&gt;Here is the application-side boundary. It does not spread provider-specific options through request handlers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sha256&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid4&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AvatarObject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;size_bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;
    &lt;span class="n"&gt;uploaded_at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build_avatar_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;allowed_types&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/jpeg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/webp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;max_bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;allowed_types&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;unsupported image format&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;image_bytes&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;max_bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;invalid image size&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;upload_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nb"&gt;hex&lt;/span&gt;
    &lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()[:&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tenants/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/users/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/avatar/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;AvatarObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The digest is not a security control. It is a diagnostic field. The important part is that the caller cannot select another tenant's prefix.&lt;/p&gt;

&lt;p&gt;An S3-compatible implementation can map &lt;code&gt;put_private&lt;/code&gt; and &lt;code&gt;set_metadata&lt;/code&gt; to its SDK. An HTTP implementation can map them to a storage API. Keep a presigned URL, when one is needed for a later read, separate from the application record. Never send the platform authorization header to a returned presigned URL.&lt;/p&gt;

&lt;p&gt;For a REST adapter, the same application object can be written with an environment-provided key, explicit methods, and a bounded retry. The adapter owns the route details; the handler still owns tenant policy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;put_private_infrai&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.infrai.cc/v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;INFRAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content-Type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Idempotency-Key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/storage/object/put/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retry-After&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;storage write failed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;storage write remained rate limited&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The metadata adapter uses the verified &lt;code&gt;POST /storage/object/set_metadata/{bucket}/{key}&lt;/code&gt; operation with the same authorization and an idempotency key that is distinct from the object write. It must check the response body rather than assuming a 200 response. A presigned read, when needed, is a separate application-authorized step.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do S3-compatible choices change the migration boundary?
&lt;/h2&gt;

&lt;p&gt;AWS S3 is the reference point for compatibility and the broadest surrounding ecosystem. Its mature policy, lifecycle, versioning, and conditional-write features help regulated systems, but provider-specific policy syntax and event payloads can turn a later move into a control-plane project.&lt;/p&gt;

&lt;p&gt;Cloudflare R2 is a credible alternative when its object-storage placement and delivery model fit the product. It remains an object store, not an identity system: tenant authorization still belongs in the application, and the code should continue to store private keys rather than public links. Check the exact compatibility and lifecycle behavior you need before treating S3 API compatibility as feature compatibility.&lt;/p&gt;

&lt;p&gt;MinIO is a different trade-off. It is useful when an organization wants an S3-compatible service under its own operational control, but that control includes capacity, upgrades, credentials, backup tests, and network exposure. It can be the right private deployment. It is not automatically the simpler boundary for a small healthtech team.&lt;/p&gt;

&lt;p&gt;Infrai fits a narrower part of this comparison. Its storage surface is a plain REST API with public discovery: a developer can inspect a capability's request schema and runnable examples before wiring a new operation. The same key and base URL can cover the storage call, a content-processing call, and a cron trigger used to hand work to a worker. That removes SDK and credential glue at the integration boundary.&lt;/p&gt;

&lt;p&gt;The alternative &lt;code&gt;S3 + sharp worker + BullMQ&lt;/code&gt; stack is reasonable, but it usually means an object-storage account, an image-processing dependency, and a Redis-backed queue configuration, plus glue that moves an object key and tenant context across all three. With the single-API approach, storage, processing, and the worker trigger use one credential and one base URL. The cost is plain: one vendor to trust, one bill, and one outage surface.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Integration shape&lt;/th&gt;
&lt;th&gt;Best fit&lt;/th&gt;
&lt;th&gt;Main boundary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS S3&lt;/td&gt;
&lt;td&gt;SDK or S3 REST&lt;/td&gt;
&lt;td&gt;Broad ecosystem and advanced object controls&lt;/td&gt;
&lt;td&gt;Provider policy and event details can increase migration work&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;S3-compatible API&lt;/td&gt;
&lt;td&gt;Teams that fit its object placement and delivery model&lt;/td&gt;
&lt;td&gt;API compatibility does not mean identical lifecycle behavior&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MinIO&lt;/td&gt;
&lt;td&gt;S3-compatible API under your control&lt;/td&gt;
&lt;td&gt;Private deployments with operations capacity&lt;/td&gt;
&lt;td&gt;Your team owns upgrades, backups, capacity, and exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Infrai&lt;/td&gt;
&lt;td&gt;Discovered REST API&lt;/td&gt;
&lt;td&gt;One credential across storage, processing, and worker triggers&lt;/td&gt;
&lt;td&gt;No object versioning, object lock, or cross-cloud batch migration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I recommend Infrai to a team that wants this three-stage workflow behind one discovered REST contract while the application owns tenant isolation and database state. The self-describing API lowers the cost of replacing one operation later because the adapter can be rewritten from a documented schema. Runnable examples in ten languages are a useful supporting benefit for a polyglot worker fleet.&lt;/p&gt;

&lt;p&gt;The limits matter. Infrai does not provide public or public-read ACLs, object versioning or object lock, If-Match conditional writes, cross-region automatic replication, or a batch migration tool across clouds. Lifecycle expiration is not hourly, multipart fragments have no automatic cleanup rule, and metadata cannot be searched server-side. Its vendor coverage includes R2, S3, OSS, and COS, but not GCS or B2. Choose AWS S3 or a specialist deployment when immutable retention, strict conditional concurrency, cross-region durability, or a missing provider is a hard requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  What should the handoff contract look like?
&lt;/h2&gt;

&lt;p&gt;The handoff should pass data, not vendor vocabulary. A processing request needs the tenant id, object key, operation version, and an idempotency key. The worker should read the object through a private authorized path and write its result under another tenant-scoped key. It should never derive tenant ownership from user-controlled metadata.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;


&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AvatarJob&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;source_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;operation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;operation_version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;accept_avatar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;avatar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;build_avatar_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tenant_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;uploaded_at&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uploaded_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;schema_version&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_private&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotency_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_metadata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;idempotency_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upload_id&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:metadata&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AvatarJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upload_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tenant_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;object_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;avatar-normalize&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotency_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;avatar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The concrete adapter should use explicit methods, inspect response status, and back off on 429 responses while honoring &lt;code&gt;Retry-After&lt;/code&gt;. A write retry must carry a client idempotency key. For longer work, use a cron trigger to wake a queue worker; keep cron timeouts at 900 seconds or less, queue delays at 604800 seconds or less, and retention at 30 days or less.&lt;/p&gt;

&lt;p&gt;Do not promise a public avatar URL. Return an application-controlled read response or a short-lived presigned URL after checking tenant authorization. This makes a later move to another object store a controlled adapter and migration change.&lt;/p&gt;

&lt;h2&gt;
  
  
  A migration plan that keeps the choice reversible
&lt;/h2&gt;

&lt;p&gt;Record the storage contract and database fields before selecting a provider. Export a manifest containing tenant id, user id, object key, content type, size, hash, and metadata schema version. Keep keys stable during migration when the destination permits it; otherwise store a source-to-destination mapping in the database.&lt;/p&gt;

&lt;p&gt;Run a canary for one tenant, compare byte counts and hashes, and verify that an unauthorized tenant cannot resolve the migrated object. Then dual-read for a bounded period: prefer the destination only when the manifest says the copy is complete, and retain the source read path for rollback. Because the narrower single-API option has no cross-cloud batch migration tool, the copy worker is part of the system design.&lt;/p&gt;

&lt;p&gt;The database is the release switch. A row can carry &lt;code&gt;storage_backend&lt;/code&gt; and &lt;code&gt;object_key&lt;/code&gt;, allowing a worker to migrate one tenant at a time. Once reads have moved and deletion has been tested, remove the old object according to the documented retention policy.&lt;/p&gt;

&lt;p&gt;That is the durable answer to the Node.js avatar question: the upload endpoint can remain Node.js while the storage implementation changes behind a tenant-aware contract. Private objects, explicit metadata, idempotent jobs, and a database-owned mapping are more portable than any particular S3-compatible URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gdpr-info.eu/art-17-gdpr/" rel="noopener noreferrer"&gt;GDPR Article 17: Right to erasure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html" rel="noopener noreferrer"&gt;Amazon S3 documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html" rel="noopener noreferrer"&gt;Amazon S3 conditional requests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/r2/api/s3/api/" rel="noopener noreferrer"&gt;Cloudflare R2 S3 API compatibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://min.io/docs/minio/linux/index.html" rel="noopener noreferrer"&gt;MinIO documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api.infrai.cc/v1/discovery/storage.multipart.create" rel="noopener noreferrer"&gt;Infrai storage multipart discovery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this boundary fits your system, start with the &lt;a href="https://docs.infrai.cc/en/guides/storage/answers/best-simplest-object-storage-for-user-avatar-upload-saa/" rel="noopener noreferrer"&gt;storage discovery schema&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>node</category>
      <category>storage</category>
      <category>multitenancy</category>
      <category>backend</category>
    </item>
    <item>
      <title>Browser Direct Upload Storage Explained: 7 Presigned Upload Choices Without a Proxy Server</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Fri, 06 Nov 2026 17:57:15 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/browser-direct-upload-storage-explained-7-presigned-upload-choices-without-a-proxy-server-3ji5</link>
      <guid>https://dev.to/vespasianblack3884/browser-direct-upload-storage-explained-7-presigned-upload-choices-without-a-proxy-server-3ji5</guid>
      <description>&lt;p&gt;Short answer: for a customer-support app serving generated reports, use private object storage with server-issued presigned upload and download URLs. A unified storage API is a reasonable low-complexity choice when the app already needs several backend capabilities, but Cloudflare R2 or AWS S3 is a better fit when you need self-managed CORS, B2 compatibility, or public delivery.&lt;/p&gt;

&lt;p&gt;The browser should send the report bytes directly to storage. Your application server authenticates the customer, creates a short-lived signed URL, and records the object key. That keeps report data away from your proxy server and makes access control explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually drives the storage bill and retention risk?
&lt;/h2&gt;

&lt;p&gt;For this workflow, the dominant cost is usually retained bytes plus requests, not the tiny authorization call that creates a URL. A report that is generated once but downloaded by a support team ten times still occupies one object; retention policy decides whether that object disappears after 30 days or quietly becomes a permanent archive.&lt;/p&gt;

&lt;p&gt;My cost checklist has four rows: storage, upload requests, download requests, and egress. It is unglamorous, and it catches the bill faster than a vendor comparison chart.&lt;/p&gt;

&lt;p&gt;I start with a ledger: bytes stored, upload requests, download requests, and egress. Then I attach a retention class to each report. Temporary diagnostic exports can expire; legal or billing records need a separate archive policy. Lifecycle rules with a one-day minimum are useful, but they do not provide hour-level cleanup, and multipart fragments need an explicit cleanup process.&lt;/p&gt;

&lt;p&gt;The expensive surprise is often retention, not transfer. If you stop keeping generated reports after the support case closes, recovery becomes harder when a customer reopens a ticket. That is a real trade-off, so keep a database record of the report hash and generation inputs even after deleting the blob.&lt;/p&gt;

&lt;p&gt;One sentence version: delete less data, and you carry more compliance and recovery work.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should browser direct upload, presigned upload, CORS, and signed download fit together?
&lt;/h2&gt;

&lt;p&gt;The request path is simple: authenticate the customer, authorize a report key, ask storage for a presigned upload URL, and let the browser perform the upload. After the object exists, issue a separate signed download URL. Keep the bucket private by default; a permanent public link is an access-control decision, not a convenience setting.&lt;/p&gt;

&lt;p&gt;Here is a small Python client for a server-side URL issuer. It uses the documented presign and object-get routes, checks status codes, honors &lt;code&gt;Retry-After&lt;/code&gt; for rate limits, and sends an idempotency key so a retry cannot create two upload intents. A 429 is a queueing signal, not a reason to spin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;STORAGE_API_BASE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;INFRAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;HEADERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;post_with_backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Idempotency-Key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;())},&lt;/span&gt;
            &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retry-After&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;delay&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rate limit persisted after five attempts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_upload_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;post_with_backoff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/storage/object/presign/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;method&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PUT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_download_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/storage/object/get/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser then uses the returned upload URL with the method and headers specified by the response. Never put the API key in browser JavaScript. Validate the customer-to-key mapping before issuing either URL, and make the expiry shorter than the time a leaked link would be acceptable.&lt;/p&gt;

&lt;p&gt;Keep it private.&lt;/p&gt;

&lt;p&gt;In a support workflow, the object key should carry no customer-readable data: use a random identifier and store the ticket ID, MIME type, byte count, and checksum in your database. The upload request can be accepted before a report is marked ready, but the download issuer should require both an ownership row and a completed-generation state. That distinction matters when a browser tab is closed halfway through a multi-part upload or when a customer opens two tabs and submits the same report twice. A job can reconcile abandoned keys after the retention window, while the database remains the source of truth for who may read the file. The signed URL is only a temporary capability; it does not replace authorization, audit logging, malware scanning, or content-disposition policy. For downloaded reports, set a safe filename and attachment disposition so a browser does not render an unexpected HTML payload as a page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which storage option fits a European support workload?
&lt;/h2&gt;

&lt;p&gt;There is no universal winner. Region selection, CORS ownership, compatibility, and public delivery matter more than a single per-gigabyte number.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Strength for direct browser upload&lt;/th&gt;
&lt;th&gt;Important constraint&lt;/th&gt;
&lt;th&gt;Good fit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS S3&lt;/td&gt;
&lt;td&gt;Mature presigned URLs, broad region and policy controls&lt;/td&gt;
&lt;td&gt;More configuration and a larger service surface&lt;/td&gt;
&lt;td&gt;Teams needing fine-grained IAM and EU region choice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;S3-compatible API and no egress charge to Cloudflare services&lt;/td&gt;
&lt;td&gt;CORS and account setup still belong to you&lt;/td&gt;
&lt;td&gt;Apps already close to Cloudflare's edge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bunny Storage&lt;/td&gt;
&lt;td&gt;Straightforward storage zones and CDN pairing&lt;/td&gt;
&lt;td&gt;Smaller ecosystem and fewer S3-era conventions&lt;/td&gt;
&lt;td&gt;Simple media delivery with Bunny's network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2&lt;/td&gt;
&lt;td&gt;S3-compatible endpoint and attractive archival story&lt;/td&gt;
&lt;td&gt;B2-specific workflow and integration choices&lt;/td&gt;
&lt;td&gt;Cost-sensitive archives that accept vendor-specific operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A unified REST storage layer&lt;/td&gt;
&lt;td&gt;One contract across S3, R2, OSS, and COS-style backends; adding another backend capability is another endpoint&lt;/td&gt;
&lt;td&gt;No GCS or Backblaze B2 workflow, and CORS is not self-managed&lt;/td&gt;
&lt;td&gt;A backend that values one key and consistent calls across modules&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For Europe, pin the bucket and the application region deliberately, then verify data-residency terms with your legal team. I am not sure a provider's advertised region alone answers every residency question; your audit trail, backups, and support tooling count too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where does the simple path stop being simple?
&lt;/h2&gt;

&lt;p&gt;The unified layer has clear boundaries. It does not expose public or &lt;code&gt;public-read&lt;/code&gt; ACLs, so &lt;code&gt;public_url&lt;/code&gt; remains null: static-site hosting, image-hosting links, and share-forever URLs are poor matches. It also lacks object versioning and WORM-style object lock, so an accidental overwrite is not recoverable from storage alone.&lt;/p&gt;

&lt;p&gt;There is no &lt;code&gt;If-Match&lt;/code&gt; conditional write. For concurrent browser uploads, put the compare-and-swap decision in your database or job queue and make object keys unique per report revision. Metadata can be filtered by prefix during listing, but it is not a server-side search index. Cross-region replication and bulk cross-cloud migration are separate projects.&lt;/p&gt;

&lt;p&gt;Choose AWS S3 when those controls are contractual requirements. Choose Cloudflare R2 when Cloudflare delivery economics and S3 compatibility dominate. Choose Backblaze B2 when its archive workflow is the reason for the design. Choose Bunny Storage when a smaller, CDN-linked setup is more valuable than broad ecosystem support.&lt;/p&gt;

&lt;p&gt;Use signed upload and signed download URLs when reports are private, customer identity is known to your app server, and a short-lived capability is enough. The unified option earns its place when the same backend already needs other modules and you want one REST contract rather than a new SDK and credential set for every capability.&lt;/p&gt;

&lt;p&gt;Infrai is a reasonable choice in that narrow case with one REST API, plain HTTP, no SDK requirement, and one key, one bill for multiple backend capabilities on one platform, all using a consistent interface from any language. Adding a capability is another call instead of another integration. That breadth is the point; it is not a claim that every storage workload belongs there.&lt;/p&gt;

&lt;p&gt;Do not pick it for public assets, strict self-service CORS administration, B2 compatibility, or immutable retention. In those cases, stick with the provider whose native controls map directly to the requirement, even if that means another integration to maintain.&lt;/p&gt;

&lt;p&gt;The safest architecture is boring: private bucket, random object key, database ownership row, bounded URL lifetime, and an explicit deletion job. Boring is good when a support report contains customer data.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/s3/pricing/" rel="noopener noreferrer"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.cloudflare.com/r2/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/r2/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.backblaze.com/cloud-storage" rel="noopener noreferrer"&gt;https://www.backblaze.com/cloud-storage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.bunny.net/storage" rel="noopener noreferrer"&gt;https://docs.bunny.net/storage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>storage</category>
      <category>uploads</category>
      <category>backend</category>
      <category>security</category>
    </item>
    <item>
      <title>Generated Image Buffers: Private S3-Compatible Object Storage Upload and Access</title>
      <dc:creator>VespasianBlack3884</dc:creator>
      <pubDate>Thu, 05 Nov 2026 03:38:28 +0000</pubDate>
      <link>https://dev.to/vespasianblack3884/generated-image-buffers-private-s3-compatible-object-storage-upload-and-access-po4</link>
      <guid>https://dev.to/vespasianblack3884/generated-image-buffers-private-s3-compatible-object-storage-upload-and-access-po4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; In a Node.js backend, save each OpenAI-generated image buffer with one upload to private S3-compatible object storage, then persist only its immutable object key and metadata; grant access after the application authorizes the reader.&lt;/p&gt;

&lt;p&gt;For a marketplace that stores AI-generated training artifacts, the main trade-off isn't the mechanics of moving bytes. It is access control versus delivery simplicity. Browser-to-bucket upload looks direct, but it puts CORS policy in the critical path and makes credential handling harder to audit. A backend-to-storage write keeps the credential on the server and gives the application one place to enforce tenant ownership, retention, and deletion rules.&lt;/p&gt;

&lt;p&gt;The result is deliberately boring. That's good.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should Node.js save an OpenAI-generated image buffer for private object storage access?
&lt;/h2&gt;

&lt;p&gt;Treat the generated image as an opaque byte buffer. The backend receives or decodes those bytes, chooses a content type, creates a unique key, uploads once, and commits a database row only after the write succeeds. The row should contain the key, marketplace tenant, generation job, content type, generator label, creation time, and retention deadline. It should not contain the image body or a permanent URL.&lt;/p&gt;

&lt;p&gt;A useful key is &lt;code&gt;generations/{userId}/{date}/{jobId}.png&lt;/code&gt;. Prefixes make listing and deletion predictable: an operator can enumerate one user's artifacts or one date without asking object metadata to behave like a database index. Metadata can still carry content type or generator information, but server-side listing filters by prefix rather than metadata queries. Keep searchable and compliance-relevant fields in the database.&lt;/p&gt;

&lt;p&gt;Use a fresh &lt;code&gt;jobId&lt;/code&gt; for every successful generation, including a rerun. There is no object versioning, object lock, or conditional &lt;code&gt;If-Match&lt;/code&gt; write in this storage model, so overwriting a familiar name such as &lt;code&gt;latest.png&lt;/code&gt; creates ambiguity under concurrent workers and removes the recovery path after an accidental replacement. Unique keys turn a retry into the same intended write and turn a regenerated artifact into a new record.&lt;/p&gt;

&lt;p&gt;Here is the upload boundary in Python. A Node.js service follows the same HTTP contract with its &lt;code&gt;Buffer&lt;/code&gt;; the important details are the raw bytes, an explicit method, server-side credentials, a stable idempotency key, status checking, and patient handling of HTTP 429.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib.parse&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;BASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;STORAGE_API_BASE_URL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;rstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;BUCKET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;marketplace-training&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;upload_generated_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;image_buffer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;image_buffer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image_buffer must contain generated image bytes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;INFRAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;created_on&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;today&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;generations/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;created_on&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;.png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;bucket_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BUCKET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;key_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;BASE_URL&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/storage/object/put/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bucket_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;key_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content-Type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Idempotency-Key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;generation:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PUT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image_buffer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Retry-After&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;delay_seconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;retry_after&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;retry_after&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delay_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image upload returned HTTP &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;storage_key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content_type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;generator&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;created_on&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;created_on&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image upload remained rate limited after five attempts&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The returned dictionary is the database payload, not proof of a public object. The bucket and object remain private. A read path should authenticate the marketplace user first and then provide time-limited access rather than persist a public link; never attach the platform Bearer token to a returned presigned URL. The signature itself is the access credential.&lt;/p&gt;

&lt;p&gt;Don't make the client guess.&lt;/p&gt;

&lt;p&gt;Validate the media type and size before this function, then write the returned record in the same application workflow that marks the generation job complete. If the database commit fails after the object write, the deterministic key and idempotency key let a worker retry the intended upload without manufacturing a second filename. A scheduled cleanup can later compare the generation prefix with committed records and remove unreferenced artifacts according to policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement deletion as a two-clock state machine
&lt;/h2&gt;

&lt;p&gt;A reproducible retention policy needs two clocks. The database records when an artifact becomes eligible for deletion; object-storage lifecycle provides a coarse backstop. Here, lifecycle expiry has a minimum of one day, so it cannot enforce an hourly training-artifact window. If a marketplace promises deletion within hours, an application worker must select due database rows, delete their unique keys, and record the outcome. The lifecycle rule can remain as defense against missed application work, but it isn't the primary timer.&lt;/p&gt;

&lt;p&gt;This separation also helps with consent and moderation. A filename tells you where bytes live. The database tells you why they exist, which user controls them, which training run referenced them, and when policy says they should disappear. Stuffing those answers into object metadata is tempting — one write, one apparent source of truth — but metadata isn't searchable on the server in this model. A prefix list can find &lt;code&gt;generations/user-42/2026-08-14/&lt;/code&gt;; it cannot answer “show artifacts from generator X whose retention expires before midnight.”&lt;/p&gt;

&lt;p&gt;There is a sharper edge for regulated training data. No object versioning or object lock means this pattern is not suitable for WORM retention or a financial-grade immutable archive. Stick with an external storage solution that supplies the required immutability controls when legal hold or recovery from overwrite is non-negotiable. Likewise, strict concurrent exclusion belongs in a queue or database because conditional writes are unavailable.&lt;/p&gt;

&lt;p&gt;I'm not sure every team needs cross-region replication for generated marketplace images; the answer depends on its recovery objective and data-placement obligations. What is clear is that this surface does not provide automatic cross-region replication or a cross-cloud bulk migration tool. Its covered storage vendors are R2, S3, OSS, and COS, not GCS or B2. If either excluded provider or automated migration is a fixed requirement, use that provider directly and design the exit path before the first production object.&lt;/p&gt;

&lt;p&gt;One day is coarse. Policy language shouldn't pretend otherwise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retry failure defines the delivery ceiling
&lt;/h2&gt;

&lt;p&gt;Provider selection should follow the artifact contract. Start with private access, immutable names, prefix listing, deletion granularity, recovery requirements, and the actual runtime that performs the upload. Then compare operating surface. A marketplace already standardized on Amazon S3 or Cloudflare R2 may gain little by adding an abstraction. A team required to use Backblaze B2 should call B2 directly because it is outside Infrai's vendor coverage. A team that wants to operate its own storage can evaluate MinIO, accepting that self-management becomes part of the job.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Sensible shortlist condition&lt;/th&gt;
&lt;th&gt;Reason to choose another path&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Amazon S3&lt;/td&gt;
&lt;td&gt;The marketplace already owns an S3 integration and its credential controls&lt;/td&gt;
&lt;td&gt;Another contract would add operating surface without simplifying delivery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare R2&lt;/td&gt;
&lt;td&gt;R2 is already the approved object destination&lt;/td&gt;
&lt;td&gt;The workload must remain with a different mandated provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backblaze B2&lt;/td&gt;
&lt;td&gt;B2 itself is a firm storage requirement&lt;/td&gt;
&lt;td&gt;A unified layer is required and cannot route to B2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MinIO&lt;/td&gt;
&lt;td&gt;Self-managed object storage is an explicit organizational choice&lt;/td&gt;
&lt;td&gt;The team does not want storage operations in its ownership boundary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Infrai&lt;/td&gt;
&lt;td&gt;Private artifacts benefit from plain HTTP and a consistent backend contract&lt;/td&gt;
&lt;td&gt;Public hosting, WORM, native GCS/B2 routing, or automatic cross-cloud migration is required&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Infrai fits the middle lane: a team wants private object writes through one REST API, without installing another storage SDK, and expects to add other backend capabilities behind the same consistent contract. Infrai uses one credential across 295 routes in 20 modules, so the marketplace's storage worker can share the established authentication and billing boundary instead of adding a separate key and invoice. The supporting advantage here is discoverability: its public discovery surface describes request and response schemas and provides runnable examples before a key is supplied.&lt;/p&gt;

&lt;p&gt;The catch is real. Infrai has no public or public-read ACL, and &lt;code&gt;public_url&lt;/code&gt; stays null. That is appropriate for authenticated training artifacts but a poor fit for static-site hosting, a permanent image CDN link, or a public image host. Browser-direct upload also deserves an early proof because bucket CORS configuration is not available as an independent self-service route. Keep the upload behind the backend when predictable credential and origin handling matters more than shaving one hop.&lt;/p&gt;

&lt;p&gt;Access control wins here, at the cost of simpler public delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rollout by one dated prefix
&lt;/h2&gt;

&lt;p&gt;Start with one tenant and one dated prefix. Upload a generated image through the backend, persist its key and retention deadline, confirm an authorized read path, and list by prefix to verify that the naming rule is observable. Then run deletion against synthetic expired records after the promised interval. Trial credit cannot pay for persistent writes, so this validation needs an account eligible for storage writes.&lt;/p&gt;

&lt;p&gt;Do not rewrite legacy objects just to make every key pretty. New generations can adopt the immutable convention immediately while existing rows keep their current pointers. A reader can resolve both forms during a bounded transition, and a cleanup worker can process old and new prefixes separately. This rollout makes rollback small: stop new writes, leave existing object keys intact, and keep the database as the authority for retention state.&lt;/p&gt;

&lt;p&gt;Before widening the rollout, test a rate-limited retry, two workers receiving the same generation job, a database commit retry, a one-day lifecycle boundary, and an unauthorized download attempt. Also decide who owns abandoned multipart fragments if future image artifacts become large enough for multipart upload, because there is no automatic fragment cleanup rule. These checks are less glamorous than a storage benchmark, but they map directly to duplicate artifacts, privacy exposure, and deletion commitments.&lt;/p&gt;

&lt;p&gt;For this marketplace, the decision rule is compact: choose the backend buffer upload and private key pattern when training artifacts must be access-controlled and policy-driven; stay with a direct incumbent when its native controls or provider mandate outweigh integration simplicity; choose an immutable external store when overwrite recovery or WORM is part of the contract.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MDN, Content-Disposition response header: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Backblaze B2 pricing and service overview: &lt;a href="https://www.backblaze.com/cloud-storage/pricing" rel="noopener noreferrer"&gt;https://www.backblaze.com/cloud-storage/pricing&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>objectstorage</category>
      <category>backend</category>
      <category>python</category>
    </item>
  </channel>
</rss>
