0

How can I upload a file to Azure Blob Storage through JMeter using JAVA programmatically?

Pratik Dey
  • 11
  • 3

1 Answers1

0

Here is a code snippet you can use as a basis:

DataLakeDirectoryClient directoryClient =
   fileSystemClient.getDirectoryClient("my-directory");

DataLakeFileClient fileClient = directoryClient.createFile("uploaded-file.txt");

File file = new File("C:\\Users\\constoso\\mytestfile.txt");

//   InputStream targetStream = new FileInputStream(file);
InputStream targetStream = new BufferedInputStream(new FileInputStream(file));

long fileSize = file.length();

fileClient.append(targetStream, 0, fileSize);

fileClient.flush(fileSize);

You can put it in a suitable JSR223 Test Element and use Groovy as the language

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133