Luchdaich suas faidhle mar thèama
Tha an stiùireadh seo a’ toirt dhut troimh-chèile pròiseas iomlan a bhith a’ cruthachadh teamplaid agus a’ luchdachadh suas faidhle PDF, ìomhaigh, no Word airson a chleachdadh mar an teamplaid sgrìobhainn agad ann an Legalesign.
A bheil feum agad air fios air ais ann an àm fìor mu phròiseas luchdachaidh suas? Faic Track Upload Progress with Subscriptions.
Dè a Dh’ionnsaicheas Tu
Aig deireadh an stiùiridh seo, bidh fios agad mar a:
- Cruthaich teamplaid ùr anns an luchd-dèanaidh Legalesign agad
- Faigh am
template IDagus anupload URLbhon fhreagairt atharrachadh - Luchdaich suas do fhaidhle tùsail chun an teamplaid
- Dèan sgrùdadh air gu bheil an luchdachadh suas soirbheachail
Riatanasan
Mus tòisich thu, dèan cinnteach gu bheil agad:
- Cunntas Legalesign le cothrom API
- Do teisteanasan dearbhaidh (faic ar stiùireadh dearbhaidh)
- Faidhle PDF, ìomhaigh, no Word deiseil airson luchdachadh suas (max 50MB)
- Am
group IDagad (an àite-obrach far a bheil thu airson an teamplaid a chruthachadh)
Am Pròiseas Iomlan
Ceum 1: Cruthaich Teamplaid
An toiseach, cruthaich teamplaid bàn ann an Legalesign. Bidh seo a’ toirt an dà chuid an template ID agus URL luchdachadh suas ro-chlàraichte airson an luchdachadh PDF. Gus seo a dhèanamh feumaidh tu ruith atharrachadh GraphQL, ma tha seo ùr dhut faic an Ro-ràdh do GraphQL.
Dè th’ ann an Teamplaid?
Is e teamplaid structar sgrìobhainn ath-chleachdadh ann an Legalesign. Cho luath ‘s a luchdaich thu suas PDF gu teamplaid, faodaidh tu:
- Raointean soidhnidh agus raointean foirme a chur ris
- A chur gu luchd-faighinn ioma
- Ath-chleachdadh airson diofar luchd-soidhnidh
Atharrachadh GraphQL
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
Caibideilean Input
{
"input": {
"groupId": "grpYourGroupAPIId",
"title": "Employment Contract Template"
}
}
Mìneachadh air Paramadairean
- groupId: ID 64-base den bhuidheann/àite-obrach agad (faodaidh tu seo fhaighinn bhon URL anns a' Chonsól https://console.legalesign.com/)
- title: Ainm mìnichte airson an teamplaid agad (faodaidh tu atharrachadh nas fhaide air adhart)
Ceum 2: Tarraing a-mach an Template ID agus an Upload URL
Tha am freagairt atharrachadh a’ toirt air ais nì templateCreateOutput. Sàbhail an raon id agus an sreang uploadUrl.
Freagairt eisimpleir:
{
"data": {
"createTemplate": {
"id": "dHBsYjQ5YTg5NWQtYWRhMy0xMWYwLWIxZGMtMDY5NzZlZmU0MzIx",
"uploadUrl": "https://s3.amazonaws.com/bucket/path?signature=..."
}
}
}
Is sreang air a chòdachadh ann am Base64 an template ID. Sàbhail an dà luach bhon fhreagairt. Tha am uploadUrl de ùine ghoirid agus bu chòir a chleachdadh gu luath.
Ceum 3: Luchdaich Suas Do PDF
Cleachd am uploadUrl a chaidh a thoirt air ais gus do fhaidhle PDF a luchdachadh suas gu dìreach gu S3. Bidh seo eadar-dhealaichte a rèir do shlat-tomhais leasachaidh. Anns an eisimpleir JavaScript againn, chleachd sinn fetch ach faodaidh tu leabharlannan eile a chleachdadh a’ gabhail a-steach aws-amplify.
Eisimpleirean Obrach Iomlan
- JavaScript
- Python
- C#
import fs from 'fs';
const AUTH_TOKEN = '<token-from-authentication-guide>';
const uploadPdfTemplate = async (groupId, title, pdfFilePath) => {
const graphqlEndpoint = 'https://graphql.uk.legalesign.com/graphql';
// Step 1: Create the template
console.log('Creating template...');
const createResponse = await fetch(graphqlEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${AUTH_TOKEN}`
},
body: JSON.stringify({
query: `
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
`,
variables: {
input: {
groupId: groupId,
title: title
}
}
})
});
const createResult = await createResponse.json();
const templateId = createResult.data.createTemplate.id;
const uploadUrl = createResult.data.createTemplate.uploadUrl;
console.log('Template created with ID:', templateId);
// Step 2: Upload the PDF
console.log('Uploading PDF...');
const fileData = fs.readFileSync(pdfFilePath);
const uploadResponse = await fetch(uploadUrl, {
method: 'PUT',
body: fileData,
headers: {
'Content-Type': 'application/pdf'
}
});
if (!uploadResponse.ok) {
throw new Error(`Upload failed: ${uploadResponse.statusText}`);
}
console.log('PDF uploaded successfully!');
return {
success: true,
templateId: templateId,
title: title
};
};
// Usage example
uploadPdfTemplate(
'grpYourGroupId',
'Employment Contract',
'./contract.pdf'
).then(result => {
console.log('Complete!', result);
}).catch(error => {
console.error('Error:', error);
});
Chan eil feum air eisimeileachd a bharrachd — tha fetch air a thoirt a-steach gu dùthchasach ann an Node.js 18+.
import requests
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
def upload_pdf_template(graphql_endpoint, auth_token, group_id, title, pdf_file_path):
transport = RequestsHTTPTransport(
url=graphql_endpoint,
headers={'Authorization': auth_token}
)
client = Client(transport=transport, fetch_schema_from_transport=True)
# Step 1: Create the template
print('Creating template...')
create_mutation = gql('''
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
''')
create_result = client.execute(
create_mutation,
variable_values={
'input': {
'groupId': group_id,
'title': title
}
}
)
template_id = create_result['createTemplate']['id']
upload_url = create_result['createTemplate']['uploadUrl']
print(f'Template created with ID: {template_id}')
# Step 2: Upload the PDF
print('Uploading PDF...')
with open(pdf_file_path, 'rb') as f:
file_data = f.read()
response = requests.put(
upload_url,
data=file_data,
headers={'Content-Type': 'application/pdf'}
)
if response.status_code != 200:
raise Exception(f'Upload failed: {response.status_code}')
print('PDF uploaded successfully!')
return {
'success': True,
'templateId': template_id,
'title': title
}
if __name__ == '__main__':
result = upload_pdf_template(
'https://graphql.uk.legalesign.com/graphql',
'Bearer YOUR_TOKEN',
'grpYourGroupId',
'Employment Contract',
'./contract.pdf'
)
print('Complete!', result)
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using GraphQL;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
using Newtonsoft.Json.Linq;
public class PdfTemplateUploader
{
private readonly GraphQLHttpClient graphQLClient;
public PdfTemplateUploader(string graphqlEndpoint, string authToken)
{
graphQLClient = new GraphQLHttpClient(graphqlEndpoint, new NewtonsoftJsonSerializer());
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", authToken);
}
public async Task<UploadResult> UploadPdfTemplate(
string groupId,
string title,
string pdfFilePath)
{
// Step 1: Create the template
Console.WriteLine("Creating template...");
var createMutation = new GraphQLRequest
{
Query = @"
mutation CreateTemplate($input: templateCreateInput!) {
createTemplate(input: $input) {
id
uploadUrl
}
}
",
Variables = new
{
input = new
{
groupId = groupId,
title = title
}
}
};
var createResponse = await graphQLClient.SendMutationAsync<dynamic>(createMutation);
string templateId = createResponse.Data.createTemplate.id;
string uploadUrl = createResponse.Data.createTemplate.uploadUrl;
Console.WriteLine($"Template created with ID: {templateId}");
// Step 2: Upload the PDF
Console.WriteLine("Uploading PDF...");
using var httpClient = new HttpClient();
var fileBytes = await File.ReadAllBytesAsync(pdfFilePath);
var content = new ByteArrayContent(fileBytes);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
var putResponse = await httpClient.PutAsync(uploadUrl, content);
if (!putResponse.IsSuccessStatusCode)
{
throw new Exception($"Upload failed: {putResponse.StatusCode}");
}
Console.WriteLine("PDF uploaded successfully!");
return new UploadResult
{
Success = true,
TemplateId = templateId,
Title = title
};
}
}
public class UploadResult
{
public bool Success { get; set; }
public string TemplateId { get; set; }
public string Title { get; set; }
}
class Program
{
static async Task Main(string[] args)
{
var uploader = new PdfTemplateUploader(
"https://graphql.uk.legalesign.com/graphql",
"Bearer YOUR_TOKEN"
);
var result = await uploader.UploadPdfTemplate(
"grpYourGroupId",
"Employment Contract",
"./contract.pdf"
);
Console.WriteLine($"Complete! Template ID: {result.TemplateId}");
}
}
Dè a Dh’Fhaodadh Tachairt An dèidh an Luchdaich Suas?
Cho luath ‘s a tha am PDF agad luchdachadh suas, thèid Legalesign gu fèin-ghluasadach:
- Sganadh airson bhìorasan - Dèan cinnteach gu bheil am faidhle sàbhailte
- Dèan dearbhadh no tionndadh air an fhaidhle - Sgrùdadh gu bheil PDFs dligheach, no tionndaidh faidhlichean taic mar sgrìobhainnean Word agus ìomhaighean gu PDF
- Tarraing a-mach fiosrachadh duilleag - Faigh cunntas is meud duilleig
- Pròiseasadh an fhaidhle - A’ dèanamh ealanta agus freagarrach airson sealladh is soidhnidh
- A’ stòradh gu tèarainte - Gluasad gu stòradh maireannach
Bidh am pròiseas seo mar as trice a’ gabhail beagan diogan. Cho luath ‘s a bhios e deiseil, tha an teamplaid agad saor airson a chleachdadh!
A’ Cur Soidhnichean agus Raointean Ris
Ma tha thu airson fèin-ghluasad a dhèanamh air com-pàirtichean agus suidheachadh nan raointean, faodaidh tu ullachadh an fhaidhle tùsail mus luchdachadh thu suas ann an grunn dhòighean eadar-dhealaichte:
- Tagaichean teacsa - Cuir tagaichean teacsa Legalesign a-steach don sgrìobhainn tùsail gus com-pàirtichean, raointean soidhnidh, agus raointean foirme a chruthachadh gu fèin-ghluasadach rè a’ phròiseasaidh. Faic mìneachadh REST API anns an tòiseachadh luath stiùireadh agus an iomradh air an t-seòladh Convert text tags.
- Raointean PDF a tha air an cuir a-steach - Ma tha do PDF mu thràth a’ toirt a-steach raointean foirme air an cuir a-steach, faodaidh Legalesign an cleachdadh mar phàirt den obair luchdachadh suas agus ullachadh teamplaid.
Na Ceumannan Air Adhart
A-nis nuair a tha teamplaid agad le PDF, faodaidh tu:
- Cuir raointean soidhnidh ris - Cleachd an atharrachadh
createTemplateElementairson raointean a chur ris - Cruthaich dreuchdan - Mìnich cò a bhios a’ soidhnigeadh an sgrìobhainn
- Cuir gu ceann-latha soidhnidh - Cleachd an atharrachadh
sendgus a chuir gu luchd-faighinn
Cùisean Cumanta is Fuasglaidhean
Mearachd "Gun chead"
Dèan cinnteach gu bheil an group ID agad ceart agus gu bheil thu air dearbhadh leis a’ chunntas ceart.
Mearachd "Faidhle ro mhòr"
Compres do PDF — is e 50MB an t-ìre as àirde.
URL Luchdaich Suas a dh’fhalbh
Cleachd an uploadUrl a chaidh a thoirt air ais leis an createTemplate sa bhad. Ma dh’fhalbh e mus luchdaich thu suas, iarr URL ùr leis an cheist upload a’ cleachdadh an template ID air a shàbhaladh.
Mearachd "PDF mì-dhligheach"
Fosgail am PDF ann an leughadair PDF gus dèanamh cinnteach gu bheil e dligheach, an uairsin às-dèanamh às ùr no sàbhaladh a-rithist e.
Sgrùdaich Pròiseas Luchdaich Suas
Gus faighinn air fios air ais ann an àm fìor mu phròiseas luchdachadh suas (sganadh, dearbhadh, crìoch) cleachd fo-sgrìobhaidhean. Faic Track Upload Progress with Subscriptions.