0

I am trying to copy a file to a windows fileshare from a playwright test. I am able to connect to the fileshare successfully but when I try to copy the file I am getting error

Error writing file to SMB: STATUS_NOT_SUPPORTED (0xC00000BB) : The request is not supported.
Test failed: Error: STATUS_NOT_SUPPORTED (0xC00000BB) : The request is not supported.

This is my fileMover.js method.

import path from 'path';
import fs, { write } from 'fs';
//import SMB2 from 'smb2';
import SMB2 from '@marsaud/smb2';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
class UCMConnectionParams {
constructor(ucmHost, ucmUserName, ucmPassword, connectionTimoutInSeconds,
smbServer) {
 this.ucmHost = ucmHost;
 this.ucmUserName = ucmUserName;
 this.ucmPassword = ucmPassword;
 this.connectionTimoutInSeconds = connectionTimoutInSeconds;
 this.smbServer = smbServer;
}
}
class UCMFileMover {
constructor(ucmConnectionParams) {
 if (!ucmConnectionParams) {
 throw new Error('Connection params missing');
 }
 this.ucmConnectionParams = ucmConnectionParams;
}
_readFileContentsIntoString(filePath) {
 try {
 return fs.readFileSync(filePath, 'utf8');
 } catch(error) {
 console.error(`Error reading file: ${filePath}`, error);
 throw error;
 }
}
_connectToSmbServer() {
 console.log(`Connecting to SMB Server: ${this.ucmConnectionParams}`);
 try {
 console.log(`this.ucmConnectionParams.ucmHost:
${this.ucmConnectionParams.ucmHost}`);
 console.log(`this.ucmConnectionParams.smbServer:
${this.ucmConnectionParams.smbServer}`);
 const smbClient = new SMB2({
 share: this.ucmConnectionParams.ucmHost,
 domain: 'MYEXT',
 username: this.ucmConnectionParams.ucmUserName,
 password: this.ucmConnectionParams.ucmPassword,
 //port: 445,
 autoCloseTimeout: this.ucmConnectionParams.connectionTimoutInSeconds 
 protocolVersion: 'SMB 2.1'
 
 });
 console.log(`Connected to
SMBserver:${this.ucmConnectionParams.smbServer}`);
 return smbClient;
 } catch(error) {
 console.error('Error connecting to SMB server', error);
 throw error;
 }
}
async copyFileToUcmDropFolder(localFilePath, relativeDestDirPath, destFileName) {
 console.log(`Preparing to copy file: ${localFilePath} to
${relativeDestDirPath}\\${destFileName}`);
 const fileBuffer = this._readFileContentsIntoString(localFilePath);
 //const fileContents = this._readFileContentsIntoString(localFilePath);
 const smbClient = this._connectToSmbServer();
 const destinationFilePath = path.join(relativeDestDirPath, destFileName);
 return new Promise((resolve, reject) => {
 smbClient.writeFile(destinationFilePath, fileBuffer, (err) => {
 if(err) {
 console.error(`Error writing file to SMB: ${err.message}`);
 return reject(err);
 } else {
 console.log(`File successfully written to:
${destinationFilePath}`);
 smbClient.exists(destinationFilePath, (existsErr, exists) => {
 if(existsErr) {
 console.error(`Error checking file existence:
${existsErr.message}`);
 } else if(exists) {
 console.log(`File confirmed at: ${destinationFilePath}`);
 } else {
 console.warn(`File not found after upload:
${destinationFilePath}`);
 }
 });
 resolve();
 }
 });
 });
 }
}
 
export { UCMConnectionParams, UCMFileMover };

I am calling this from my playwright test (spec file)

import { test, expect } from '@playwright/test';
import path from 'path';
import { UCMConnectionParams, UCMFileMover } from '../../helpers/fileMover.js';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
test('File mover to UCM', async() => {
 const sourceFile = path.join(__dirname, 'test_file.txt');
 const ucmHost = '\\\10円.xx.xx.xx\\fixfixer\\';
 const userName = 'MYEXT\\feeds';
 const password = 'xxxxx';
 const timeoutInMs = 5000;
 const ucmParams = new UCMConnectionParams(
 ucmHost,
 userName,
 password,
 timeoutInMs,
 '10.xx.xx.xx'
);
const fileMover = new UCMFileMover(ucmParams);
const localFile = path.join(__dirname, 'test_file.txt');
const relativeDestDir = 'clients\\DEV\\clientxxx\\TESTCLIENT_xxx_PRIMARY_LOADER';
const destFileName = 'uploaded_file.txt';
try {
 await fileMover.copyFileToUcmDropFolder(localFile, relativeDestDir,
destFileName);
 console.log('File copied successfully');
} catch(error) {
 console.error('Test failed: ', error);
 throw error;
}
});

This is the log message I see when running this test.

`Preparing to copy file: C:\Users\xx\repo\my-repo\tests\UCM\test_file.txt to
clients\DEV\clientxxx\TESTCLIENT_xxx_PRIMARY_LOADER\uploaded_file.txt
Connecting to SMB Server: [object Object]
this.ucmConnectionParams.ucmHost: \10円.xx.xx.xx\fixfixer\
this.ucmConnectionParams.smbServer: 10.xx.xx.xx
Connected to SMB server: 10.xx.xx.x`

From this, it looks like I am able to connect to the fileshare, but the copy file operation fails.

Any help in resolving this much appreciated.

I tried to copy a local file from windows to windows file share using SMB2 protocol in node.js. I want to call this file mover from my playwright test. Alternatively I tried using "net use" and I am able to copy the file successfully to file share. But I want to use SMB instead of net use.

Expected: File successfully copied to windows fileshare (password protected) Actual: Error when copying file to the file share.

Error writing file to SMB: STATUS_NOT_SUPPORTED (0xC00000BB) : The request is not supported.

Christian Baumann
3,7614 gold badges24 silver badges48 bronze badges
asked Mar 13, 2025 at 19:57

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.