Developer forum

Forum » Integration » Best way to upload PDFs to Assets from an external system to DW10?

Best way to upload PDFs to Assets from an external system to DW10?

Davy Capiau
Reply

Hi all,

We’re on Dynamicweb 10 and need an external system to automatically add PDFs to a specific Assets folder. FTP is no longer possible.

We see these options and are unsure what’s best practice:

  1. External system uses the Dynamicweb CLI (with a dedicated API key/service account) - 

    1. How does the external system integrates the DW CLI?

  2. External system uploads directly via API (if there’s a supported upload endpoint -> seems there is none?)

  3. Pull model: DW fetches PDFs from external storage/endpoint 

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Davy

If you can run an FTP on your remote server, you can run the CLI. The CLI runs on 'anything' - even on edge functions.

Adding a section to the docs - something like this:

 

Scheduling a Dynamicweb CLI Command on Windows

This article explains how to schedule a Dynamicweb CLI (Command-Line Interface) command on a Windows server using Task Scheduler and includes guidance for uploading files from a local folder into a Dynamicweb solution via the CLI.

Dynamicweb CLI is a powerful command-line tool that helps manage environments, automate tasks, work with files in the Dynamicweb solution, install add-ins, export database and files, and run queries or commands through the Management API.(doc.dynamicweb.dev)

Prerequisites

Before scheduling automation, verify:

  • The Dynamicweb CLI is installed:

    npm i @dynamicweb/cli -g
    

    or follow the CLI installation instructions.(doc.dynamicweb.dev)

  • The CLI can connect to the environment:

    dw login
    

    or use a pre-generated API key.(doc.dynamicweb.dev)

  • Your CLI command runs successfully from a normal Command Prompt.

This ensures proper authentication and configuration before scheduling the task.

Step 1: Create a Batch File

Wrap your CLI command in a .bat file to control working directory and capture logs.

  1. Create a folder for scripts, for example:
    C:\Scripts

  2. Create a file:
    C:\Scripts\dynamicweb-job.bat

  3. Add the following content:

    @echo off
    cd /d C:\Path\To\Your\CLI
    
    dwcli.exe sync products --env Production >> C:\Scripts\logs\dw-job.log 2>&1
    
    • cd /d sets the working directory.

    • >> … 2>&1 captures output and errors to a log file.

Step 2: Windows Task Scheduler

Open Task Scheduler and create a new task:

  • General

    • Name the task (e.g., Dynamicweb Product Sync)

    • Select “Run whether user is logged on or not”

    • Enable “Run with highest privileges”

  • Triggers
    Set schedule (e.g., daily at 02:00)

  • Actions

    • Action: “Start a program”

    • Program/script: C:\Scripts\dynamicweb-job.bat

    • Start in: C:\Scripts

  • Conditions/Settings
    Adjust power/network settings as required.

Provide credentials when prompted.

Votes for this answer: 1
 
Jelle Deridder
Reply

Hi Nicolai,

Thanks, just to confirm I understand your recommended approach correctly:

  • Customer/external system provides a machine/environment where the files are available
  • They install Dynamicweb CLI there
  • They run a scheduled job that picks up files and pushes them into the target assets folder in DW via CLI

One concern: for an automated job we prefer a dedicated API key with minimal permissions (ideally only the file upload/import part). What’s the recommended best practice in DW10 to set this up securely?

Thanks!

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jelle

Yes, that is the suggestion.

You can create a dedicated key in the backend - and assign it to a user context.

Currently the management API does not contains permissions. But it is on our radar.

Votes for this answer: 1

 

You must be logged in to post in the forum