Keep a PDF result tied to the right Google Drive file

4 August 2026

An overhead view of hands typing on a laptop beside a notebook.
Illustrative photograph. Cropped and resized. Photo: “Computer Laptop Working” — Design by Matt / NegativeSpace. · CC0 1.0

Two Drive files can have the same name. A filename also says little about the version a person selected or where a derivative may be written. Work through this six-case local simulation to follow the source identity, approval and destination across a retry, then check the assumptions against your own Drive setup.

Which source and destination did the person approve?

Suppose an operations team wants to create review copies from PDFs stored in a shared drive. Reviewers need the output in a controlled folder, while the source remains available unchanged. The integration must answer three questions: which source state was processed, where the derivative belongs, and who can access each copy.

Record whether the source is in My Drive or a shared drive. Google documents differences in shared-drive ownership and organisation, and requires applications supporting relevant shared-drive operations to declare that support. A connector working with a user's personal test folder has therefore not established shared-drive compatibility. Consult Google's shared-drive implementation guidance.

Where this guidance stops

This is a proposed contract for Drive API v3 and a separate processing service. No native ArkePDF connector or authenticated Drive execution is demonstrated. The design handles file provenance and access; selecting an OCR engine, evaluating conversion quality and defining a legal retention period require additional decisions.

Set scopes and access prerequisites

Official Drive API scopes and file access

Choose access around the actual selection and processing workflow. Google's drive.file scope covers files created by the app or opened or shared with it through the relevant app interaction; it is not unrestricted access to every file in a user's Drive. Evaluate whether that narrower model meets the use case before requesting broader scopes. See the official scope guidance.

PrerequisiteEvidence to retain
Account and authentication modelRuntime identity and consent record
Source fileFile ID, MIME type and captured version
Storage contextMy Drive or named shared drive
DestinationExplicit drive and folder IDs
Processing authorityWho may submit, retrieve and approve results
Return policyNew derivative or controlled update

Define the input type before downloading. A PDF stored as binary content follows a different path from a native Google document exported as PDF. Google's download guidance uses files.get with alt=media for blob content and files.export for Google Workspace document exports. Capture which route was used in the provenance record. See download and export methods.

Keep the source access decision separate from permission to upload elsewhere. A user may be allowed to read an input without being authorised to create a copy in a broader audience's folder. The approved destination should be part of the job contract, not a free-text field supplied by an untrusted event.

Six simulated Drive contract checks

Inputs, assumptions and the expected result

The synthetic processing contract selects file SYN-F01, version 7, in shared drive SYN-SHARED-01. A proposed review operation may place a new derivative in folder SYN-FOLDER-09 of that same shared drive. The source checksum identifies labelled placeholder bytes; it is not a checksum of a document downloaded from Google.

In a real implementation, capture metadata, obtain the permitted input bytes and bind them to that captured state. Submit the bounded processing request. Before committing its result, re-evaluate access and confirm that the source still satisfies the agreed version policy. Upload the derivative, retain its new file ID, and read back its metadata and access behaviour. Store the source and derivative IDs as two separate identities.

The proposed flow is:

FromConditionNext step
Source metadata and accessAlwaysInput type
Input typePDF blobAcquire PDF bytes
Input typeGoogle documentApproved PDF export
Acquire PDF bytesAlwaysBounded processing job
Approved PDF exportAlwaysBounded processing job
Bounded processing jobAlwaysDerivative with source relationship

Drive's version field is a monotonically increasing number reflecting server-side changes, including changes that are not visible to the user. It should not be interpreted as a content checksum. The Files resource defines its meaning. A version change with identical bytes can still require a routing or permission review.

The accompanying Python simulation was executed locally with Python 3.12.14. Six cases produced the expected outcomes:

CaseObserved local model outcome
Approved PDF requestOne derivative record
Repeated requestExisting derivative record reused
Version changes but checksum stays equalHeld for review
Destination changes to a different driveRejected
Access is revokedHeld
Native Google document supplied to PDF routeHeld for export selection

The result file retains every request, model state and decision. The first two cases together created one derivative record. The changed-version case deliberately did not infer that identical bytes made the new state acceptable.

What the results establish

This is an executed local contract model, not a Google API response transcript. It exercised no OAuth token, downloaded no Drive file and uploaded no PDF. It establishes how the proposed rules respond to these inputs. Actual shared-drive access, export behaviour and concurrent writes remain matters for a controlled integration test.

Handle duplicates and changed files

Retries, revisions and concurrent updates

Use a job key that combines the scoped source identity, captured state, operation version and approved destination. Keep event-delivery identifiers separately. This allows a repeated notification to recover an existing job while preserving a distinct request for a later document state.

A name change should not cause the application to lose its source reference. Equally, a matching name must not cause it to select another file. Refresh display metadata through the stored ID and record relevant changes without rewriting history. If the item becomes inaccessible, classify that as an unresolved access condition rather than assuming it has been deleted.

After a timeout during upload, reconcile before creating again. The application needs evidence linking a remote output to its job, not just a folder search for the intended filename. If that association cannot be established, hold the ambiguous job and investigate. A guessed retry can create duplicate review copies that users mistake for independent versions.

Define whether a result remains acceptable when the source changes during processing. A strict workflow may reject it. A historical-analysis workflow may retain it with an explicit source-state label. Both can be coherent; silently presenting an older output as current cannot. Record the policy version used when the job was accepted.

Acceptance checklist for a Google Drive PDF processing integration

Least privilege and reproducible end-to-end tests

Run the first authenticated test in an approved Drive environment using visibly synthetic PDFs. Keep the exact source IDs, captured versions, destination IDs and runtime identity in a restricted test record. Successful access with an administrator account does not prove the intended integration account has the right boundary.

Require evidence that:

  • The selected PDF produces a derivative with a recorded source relationship.
  • The intended reviewer can open it and an unauthorised reviewer cannot.
  • A wrong destination drive is rejected before upload.
  • Repeated delivery and an uncertain upload response are reconciled without extra outputs.
  • A source change is handled according to the documented state policy.
  • A native Google document takes the approved export route or receives an intelligible exception.
  • Revocation prevents further processing or retrieval as specified by the design.

Measure completion time, queue growth and recovery after throttling using the intended document sizes. Record the configured request and concurrency limits alongside observations. Distinguish a request accepted by the service from a result reconciled into Drive; only the latter completes this workflow.

Maintain the integration

Deployment, rollback and support ownership

Assign an owner to the Drive configuration, an owner to processing quality and an owner to unresolved jobs. Establish who can approve a change of destination or access scope. Review those settings when teams reorganise or the integration identity changes.

Version the contract and deploy changes against a small, bounded document set. If a release routes outputs incorrectly, pause intake and identify derivatives by their recorded job relationships. Do not rely on filenames or remove unrelated folder contents. Preserve source files and evidence while the owner decides which outputs should be withdrawn or recreated.

For a proof of concept, bring the synthetic contract, six local cases and a proposed permission boundary. Ask the implementer to demonstrate the full source-to-derivative trace in the intended Drive context before accepting compatibility or operational-readiness claims.

Sources

Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with ChatGPT. Editorial and technical checks by Kairos (Codex).