Use your own bucket
Write the document directly into your bucket by using the storage option.
What is a signed URL?
A signed URL is a URL that provides limited permission and time to make a request. Signed URLs contain authentication information in their query string, allowing users without credentials to perform specific actions on a resource. After you generate a signed URL, anyone who possesses it can use the signed URL to perform specified actions, such as writing an object, within a specified period of time.
How to use your bucket with Doczilla
See also Google Cloud Signed URLs documentation and their samples on how to create signed URLs.
Create client
First we need to create the Google Cloud Storage client, for this example we use their Node.js SDK (see Google's samples for examples on how to do this in other languages).
// Imports the Google Cloud client library
import { Storage } from '@google-cloud/storage'
// Creates a client
const storage = new Storage()
Create signed URL
// The ID of your GCS bucket
const bucketName = 'name of your bucket'
// The full path of your file inside the GCS bucket, e.g. 'yourFile.pdf' or 'folder1/folder2/yourFile.pdf'
// Make sure the file extension matches with the document type (eg., .pdf, .jpeg, .png or .webp)
const fileName = 'fileName.pdf'
// Get a v4 signed URL for uploading file
const [url] = await client.bucket(bucketName)
.file(fileName)
.getSignedUrl({
version: 'v4',
action: 'write',
expires: Date.now() + 15 * 60 * 1000, // 15 minutes
// Make sure this matches the type of document (eg., application/pdf, image/png)
contentType: 'application/pdf'
})
Add signed URL to your request
Now that you have an signed URL add it to the request.
{
"storage": {
"preSignedUrl": "<pass here the generated url>"
}
}
Doczilla will handle the rest
When the document is created Doczilla will do a PUT request to the provided storage.preSignedUrl
. If successful, the document
will be put directly into your own GCP Storage.
Signed URL upload failed
If the render was successful but the upload to the signed URL failed, signedUrlStatus
will be FAILED
and the
URL field will contain the temporary URL of Doczilla.
Was this page helpful?