jcifs.smb.SmbException: The parameter is incorrect

Рейтинг: 1Ответов: 0Опубликовано: 28.03.2023

Хочу передать файл по локальной сети, решил попробовать сделать это с библиотекой JCISF, но выдает ошибку. Код и ошибка ниже.

Код:

val fileName = "db.xlsx"
            val fileContent = "This is some text that will be written to the file."

            try {
                val file = File(applicationContext.getExternalFilesDir("db"), fileName)
                val outputStream = FileOutputStream(file)
                outputStream.write(fileContent.toByteArray())
                outputStream.close()
                Log.i("File", "File saved successfully.")
            } catch (e: Exception) {
                Log.e("File", "Error saving file: ${e.message}")
            }
            Thread {
                //Do some Network Request
                val sourceAuth = NtlmPasswordAuthenticator(null,"smbtest","0000")
                val localSourceUrl = "smb://ARABRO/smb-test/"
                val properties = Properties()
                properties.setProperty("jcifs.smb.client.responseTimeout", "5000")
                val configuration = PropertyConfiguration(properties)
                val cifsContext = BaseContext(configuration).withCredentials(sourceAuth)

                val filepath = File(getExternalFilesDir("db"), "db.xlsx")
                val sourceDir = SmbFile(localSourceUrl, cifsContext)
                val fileStream = FileInputStream(filepath)
                val outStream = sourceDir.outputStream

                fileStream.use { inputStream ->
                    outStream.use { outputStream ->
                        inputStream.copyTo(outputStream) // копируем содержимое файла в выходной поток
                        outputStream.flush()
                        outputStream.close()
                    }
                }
                runOnUiThread {
                    Toast.makeText(this,"d", Toast.LENGTH_LONG).show()
                }
            }.start()

Ошибка:

W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
W/System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation
W/System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
W/mple.jcisf_tes: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLProvider;-><init>()V (greylist,core-platform-api, reflection, allowed)
W/mple.jcisf_tes: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLRandom;-><init>()V (greylist, reflection, allowed)
E/AndroidRuntime: FATAL EXCEPTION: Thread-2
    Process: com.example.jcisf_test, PID: 13487
    jcifs.smb.SmbException: The parameter is incorrect.
        at jcifs.smb.SmbTransportImpl.checkStatus2(SmbTransportImpl.java:1457)
        at jcifs.smb.SmbTransportImpl.checkStatus(SmbTransportImpl.java:1568)
        at jcifs.smb.SmbTransportImpl.sendrecv(SmbTransportImpl.java:1023)
        at jcifs.smb.SmbTransportImpl.send(SmbTransportImpl.java:1539)
        at jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:409)
        at jcifs.smb.SmbTreeImpl.send(SmbTreeImpl.java:472)
        at jcifs.smb.SmbTreeConnection.send0(SmbTreeConnection.java:401)
        at jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:315)
        at jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:295)
        at jcifs.smb.SmbTreeHandleImpl.send(SmbTreeHandleImpl.java:130)
        at jcifs.smb.SmbTreeHandleImpl.send(SmbTreeHandleImpl.java:117)
        at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:123)
        at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:95)
        at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:76)
        at jcifs.smb.SmbFile.getOutputStream(SmbFile.java:2134)
        at com.example.jcisf_test.MainActivity.onCreate$lambda$4$lambda$3(MainActivity.kt:49)
        at com.example.jcisf_test.MainActivity.$r8$lambda$YKbsLPTora59WkDzQYd0kZmG0Uk(Unknown Source:0)
        at com.example.jcisf_test.MainActivity$$ExternalSyntheticLambda2.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:923)
W/System: A resource failed to call close. 

Ответы

Ответов пока нет.