From dc95ba023daabacb9c83f183498dcab6d6b1bd73 Mon Sep 17 00:00:00 2001 From: Mam Thenebo Date: Mon, 15 Apr 2024 19:29:24 +0330 Subject: [PATCH] feat: Add support for asynchronous PDF to Word conversion with callback URL and update usage instructions --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index 210a802..f4a828e 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,56 @@ tail -f ./logs/* This command tails the log files, offering a live view into the application’s operational logs. +## New Features + +### Callback URL Support + +The application now includes the ability to process PDF to Word conversions asynchronously. Once the conversion process is complete, the converted `.docx` file is sent to a specified callback URL. This feature allows the processing to occur in the background, freeing up clients to perform other tasks rather than waiting for a synchronous response. + +## Updated Usage Instructions + +### Asynchronous Conversion with Callback URL + +1. **Trigger the Conversion**: + To request a PDF conversion and have the application send the resulting `.docx` file to a callback URL once processing is done, use the curl command as follows: + + ```bash + curl -X POST -F "file=@path_to_your_pdf_file.pdf" \ + -F "callback_url=http:///callback" \ + http://localhost:4000/upload-pdf + ``` + + Replace `path_to_your_pdf_file.pdf` with the path to your actual PDF file, and `` with your service's callback URL. + +2. **Callback Server Setup**: + Prepare your callback server to handle incoming POST requests at the `/callback` endpoint. The server should process the incoming `.docx` file as per your application's logic. + +### Example Callback Endpoint + +Here's an example Flask route that could serve as your callback endpoint: + +```python +@app.route('/callback', methods=['POST']) +def callback(): + file = request.files['file'] + # Implement file handling logic here + return jsonify({'message': 'File received successfully'}), 200 +``` + +This endpoint will be invoked with the converted .docx file after the PDF conversion is complete. + +### Test Command for Callback Feature + +To test the callback functionality, you can use the following curl command. This will send a PDF file to the /upload-pdf endpoint along with a callback_url. After the PDF is processed, the application will send the converted .docx file to the provided callback URL: + +```bash +curl -X POST -F "file=@uploads/sample_input.pdf" \ + -F "callback_url=http://localhost:5000/callback" \ + http://localhost:4000/upload-pdf +``` + +Be sure to replace `http://localhost:5000/callback` with your actual callback endpoint that's ready to accept the file. + ## Configuration Details ### Environment Variables