This commit is contained in:
2026-02-18 19:40:41 +07:00
parent a9821b1ae6
commit 483caab54c
3 changed files with 14 additions and 13 deletions

View File

@@ -26,9 +26,6 @@ correlation_id = string(uuid4())
# test file transfer #
# ------------------------------------------------------------------------------------------------ #
# File path for large binary payload test
const FILE_PATH = "./testFile_large.zip"
const filename = basename(FILE_PATH)
# Helper: Log with correlation ID
function log_trace(message)
@@ -65,18 +62,27 @@ end
# Sender: Send large binary file via smartsend
function test_large_binary_send()
# Read the large file as binary data
log_trace("Reading file: $FILE_PATH")
file_data = read(FILE_PATH)
file_size = length(file_data)
log_trace("File size: $file_size bytes")
# test data 1
file_path1 = "./testFile_large.zip"
file_data1 = read(file_path1)
filename1 = basename(file_path1)
data1 = (filename1, file_data1, "binary")
# test data 2
file_path2 = "./testFile_small.zip"
file_data2 = read(file_path2)
filename2 = basename(file_path2)
data2 = (filename2, file_data2, "binary")
# Use smartsend with binary type - will automatically use link transport
# if file size exceeds the threshold (1MB by default)
# API: smartsend(subject, [(dataname, data, type), ...]; keywords...)
env = NATSBridge.smartsend(
SUBJECT,
[(filename, file_data, "binary")], # List of (dataname, data, type) tuples
[data1, data2], # List of (dataname, data, type) tuples
nats_url = NATS_URL;
fileserver_url = FILESERVER_URL,
fileserverUploadHandler = plik_upload_handler,
@@ -105,7 +111,6 @@ end
# Run the test
println("Starting large binary payload test...")
println("Correlation ID: $correlation_id")
println("File: $FILE_PATH")
# Run sender first
println("start smartsend")