Гость
Форумы / Android [игнор отключен] [закрыт для гостей] / Как скачать файл из расшаренной папки в локальной сети? / 3 сообщений из 3, страница 1 из 1
17.06.2014, 11:34
    #38671463
VladC#
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Как скачать файл из расшаренной папки в локальной сети?
Разрабатываю приложение под Android, мне нужно скачивать файлы из локальной сети, как это сделать?
...
Рейтинг: 0 / 0
17.06.2014, 12:00
    #38671498
wadman
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Как скачать файл из расшаренной папки в локальной сети?
http://jcifs.samba.org/

The Java CIFS Client Library
JCIFS is an Open Source client library that implements the CIFS/SMB networking protocol in 100% Java. CIFS is the standard file sharing protocol on the Microsoft Windows platform (e.g. Map Network Drive ...). This client is used extensively in production on large Intranets.

Пример, как работать: http://stackoverflow.com/questions/14559019/write-upload-a-file-using-samba-jcifs-issue-smbauthexception-access-is-denied?lq=1

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
    public boolean save2Samba(String text, String fileName) {
        try {

            // My Windows shares doesn't require any login/password
            // String name="login";//my windows username
            // String password="password1";//my windows password

            // sSambaFolder contains a path like MYPC/E/SharedFolderName/
            String url = "smb://" + sSambaFolder.toLowerCase()+fileName;

            SmbFile file = null;
            try {
                // assume ANONYMOUS is my case but there is no description of this in JCIFS API
                NtlmPasswordAuthentication auth = NtlmPasswordAuthentication.ANONYMOUS;
                file = new SmbFile(url, auth);
                android.util.Log.i("TestApp",url);
                // output is like smb://mypc/e/sharedfoldername/file.txt;
                SmbFileOutputStream out = new SmbFileOutputStream(file);
                out.write(text.getBytes());
                out.flush();
                out.close();

            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }

            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }


Анонимная аутентификация
Код: java
1.
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, null, null);
...
Рейтинг: 0 / 0
17.06.2014, 12:46
    #38671613
VladC#
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Как скачать файл из расшаренной папки в локальной сети?
Похоже то, что надо, спасибо, буду пробовать.
...
Рейтинг: 0 / 0
Форумы / Android [игнор отключен] [закрыт для гостей] / Как скачать файл из расшаренной папки в локальной сети? / 3 сообщений из 3, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]