Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL with parameters #47

Open
forcecodema opened this issue Jan 12, 2023 · 0 comments
Open

URL with parameters #47

forcecodema opened this issue Jan 12, 2023 · 0 comments

Comments

@forcecodema
Copy link

forcecodema commented Jan 12, 2023

There seems to be a problem when the url passed to print the document from contains parameters. Example log file contains the following:

14:33:48.753 [DESKTOP-0UKK3G6][WebSocketWorker-46] INFO  tigerworkshop.webapphardwarebridge.utils.DownloadUtil.file() @21 - Downloading file from: https://some.domain.name/move/label/fetch?zpl=1&raw=1&itemId=32521&qty=10
14:33:49.228 [DESKTOP-0UKK3G6][WebSocketWorker-46] ERROR tigerworkshop.webapphardwarebridge.websocketservices.PrinterWebSocketService.onDataReceived() @61 - java.io.FileNotFoundException
14:33:49.229 [DESKTOP-0UKK3G6][WebSocketWorker-46] DEBUG tigerworkshop.webapphardwarebridge.websocketservices.PrinterWebSocketService.onDataReceived() @62 - documents\fetch?zpl=1&raw=1&itemId=32521&qty=10 (Nazwa pliku, nazwa katalogu lub składnia etykiety woluminu jest niepoprawna)
java.io.FileNotFoundException: documents\fetch?zpl=1&raw=1&itemId=32521&qty=10 (Nazwa pliku, nazwa katalogu lub składnia etykiety woluminu jest niepoprawna)

The error is that the filename output from getPathFromUrl function is incorrect.

public static String getPathFromUrl(String urlString) {
    urlString = urlString.replace(" ", "%20");
    String filename = urlString.substring(urlString.lastIndexOf("/") + 1);
    return Config.DOCUMENT_PATH + filename;
}

I would suggest to either escape the filename so it produces a valid filename or generate filename randomly. Something like this would do the trick, especially that the file is deleted after sending to printer or print queue.

import java.util.UUID;

public static String getPathFromUrl(String urlString) {
    return Config.DOCUMENT_PATH + UUID.randomUUID().toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant