TextMaster's Developer Documentation
HomeApp
  • Welcome!
  • Quick Start
    • Postman
    • OpenAPI
  • Overview
    • Resources in the REST API
    • Authentication
    • Troubleshooting
    • Filters
    • Workflow
    • File uploads
    • Loop
  • Guides
    • Integrator best practices
  • Apps
    • About OAuth Apps
    • Building OAuth Apps
      • Creating an OAuth App
      • Authorizing OAuth Apps
      • Scopes for OAuth Apps
    • Managing OAuth Apps
      • Modifying an OAuth App
      • Deleting an OAuth App
  • Webhooks & Events
    • Webhooks
      • Creating webhooks
      • Configuring your server for webhooks
      • Securing webhooks
      • Troubleshooting webhooks
    • Events
  • Integrations
    • Akeneo
      • Getting Started
      • Configuration
      • Usage
      • Monitoring
      • Troubleshooting
    • Salesforce Commerce Cloud
      • Getting Started
      • Configuration
      • Usage
      • Monitoring
      • Troubleshooting
  • Reference
    • Abilities
    • Authors
    • Documents
    • Categories
    • Countries
    • Expertises
    • Glossaries
    • Languages
    • Levels
    • Locales
    • Preferred Authors
    • Projects
    • Project Templates
    • Negotiated Contracts
    • Support Messages
    • Transactions
    • Uploads
    • Users
    • Work Templates
Powered by GitBook
On this page

Was this helpful?

  1. Reference

Uploads

PreviousTransactionsNextUsers

Last updated 1 year ago

Was this helpful?

Get upload properties for a file

Get upload properties for a file a client wish to upload on TextMaster. Theses properties can then be used to make the HTTP request on the storage provider with the file sent as HTTP form data.

OAuth: This endpoint requires the default public scope.

Code samples

curl "https://api.textmaster.com/v1/clients/upload_properties" \
  -X POST \
  --data-urlencode "file_name=my-file.pdf" \
  --data-urlencode "hashed_payload=f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2" \
  -H "Authorization: Bearer 427ba17dc03db4792cd8d3c731ed53addd261b1baa7eef1ceda2cf2ca20f2b79"

# Response:
#
# {
#   "url": "https://storage-proxy.textmaster.com/api-files/uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9f1ca8/my-file.pdf",
#   "headers": {
#     "x-upload-path": "uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9e1ca8/my-file.pdf",
#     "x-upload-sha256": "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e39b7605022da52e6ccc26fd2",
#     "x-upload-date": "20500102T123456Z",
#     "Authorization": "78ca271e7f6464961ef3db6903da3d2c51cd4156975322ba678840e12a334de3"
#   }
# }

curl "https://storage-proxy.textmaster.com/api-files/uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9f1ca8/my-file.pdf" \
  -X PUT \
  -H "x-upload-path: uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9e1ca8/my-file.pdf" \
  -H "x-upload-sha256: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e39b7605022da52e6ccc26fd2" \
  -H "x-upload-date: 20500102T123456Z" \
  -H "Authorization: 78ca271e7f6464961ef3db6903da3d2c51cd4156975322ba678840e12a334de3" \
  -H "Content-Type: application/pdf" \
  -d "@path/to-the-actual-file/my-file.pdf"

This sample Ruby code requires the excon gem to be installed.

require 'digest/sha1'
require 'excon'
require 'json'
require 'time'

file_name      = 'my-file.pdf'
file_path      = 'path/to-the-actual-file/my-file.pdf'
file_content   = File.binread(file_path)
hashed_payload = Digest::SHA256.hexdigest(file_content)

apikey = 'YOUR TEXTMASTER API KEY'
apisecret = 'YOUR TEXTMASTER API SECRET'
current_time = Time.now.utc.httpdate
signature = Digest::SHA1.hexdigest(apisecret + current_time)

response = Excon.post(
  'https://api.textmaster.com/v1/clients/upload_properties.json',
  body: URI.encode_www_form(file_name: file_name, hashed_payload: hashed_payload),
  headers: {
    apikey: apikey,
    date: current_time,
    signature: signature,
  }
)

properties = JSON.parse(response.body)
# {
#   "url" => "https://storage-proxy.textmaster.com/api-files/uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9f1ca8/my-file.pdf",
#   "headers" => {
#     "x-upload-path" => "uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9e1ca8/my-file.pdf",
#     "x-upload-sha256" => "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e39b7605022da52e6ccc26fd2",
#     "x-upload-date" => "20500102T123456Z",
#     "Authorization" => "78ca271e7f6464961ef3db6903da3d2c51cd4156975322ba678840e12a334de3"
#   }
# }

response = Excon.put(
  properties['url'],
  body: file_content,
  headers: properties['headers'].merge('Content-Type' => 'application/pdf')
)

response.status
#=> 200
  • Get upload properties for a file
  • POSTGet Upload Properties

Get Upload Properties

post
Authorizations
Body
file_namestringRequired

File name for the uploaded file

hashed_payloadstringRequired

SHA256 digest of the file content

Responses
200
File Uploaded
application/json
post
POST /v1/clients/upload_properties HTTP/1.1
Host: api.textmaster.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 44

"file_name='text'&hashed_payload='text'"
200

File Uploaded

{
  "url": "https://storage-proxy.textmaster.com/api-files/uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9f1ca8/my-file.pdf",
  "headers": {
    "x-upload-path": "uploads/10922fb8-9265-4ef2-92e8-c4177c3b03da/ef9e1ca8/my-file.pdf",
    "x-upload-sha256": "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e39b7605022da52e6ccc26fd2",
    "x-upload-date": "20500102T123456Z",
    "Authorization": "78ca271e7f6464961ef3db6903da3d2c51cd4156975322ba678840e12a334de3"
  }
}