PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV Mobile 2024
→
Télécharger images du réseau
Télécharger images du réseau
Started by Service Informatique, Oct., 23 2019 4:44 PM - 1 reply
Connect yourself…
Service Informatique
#1
Posted on October, 23 2019 - 4:44 PM
Bonjour,
J'ai intégré du code java sur mon application Windev Mobile, ce code sert à explorer le réseau et télécharger les fichiers que l'on veut.
Mon but est de télécharger des images, j'arrive à télécharger mes images lorsque j'utilise ce code sous éclipse
J'arrive aussi à télécharger les images lorsque j'utilise ce code dans Windev Mobile, mais les images ayant une taille supérieur à 1200-1300 Ko ne sont pas bien télécharger, elles ne s'affichent pas lorsque je les ouvre dans un explorateur d'image "Impossible de charger cette image."
Y aurait-il une solution ?
Voici le code java :
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
public static void SMB(String nom) {
String user = "user";
String pass = "pass";
InputStream in = null ;
ByteArrayOutputStream out = null ;
String sharedFolder="Photos/Peinture";
String path="smb://serveur/"+sharedFolder+"/Img_0001.jpg"; // Remplacer Img_0001.jpg par nom
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domaine",user, pass);
SmbFile smbFile = null;
try {
smbFile = new SmbFile(path,auth);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Create a remote file object
try {
smbFile.connect();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} //Try to connect
//Create a file stream
try {
in = new BufferedInputStream(new SmbFileInputStream(smbFile));
} catch (SmbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
out = new ByteArrayOutputStream((int)smbFile.length());
} catch (SmbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Read the contents of the documents
byte[] buffer = new byte[4096];
int len = 0; //Read length
try {
while ((len = in.read(buffer, 0, buffer.length)) != - 1) {
out.write(buffer, 0, len);
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
out.flush();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} //The refresh buffer output stream
System.out.println(out.toByteArray());
byte[] src = out.toByteArray();
File img = new File("//sdcard/Android/data/com.masociete.DonneesProd/", nom);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(img.getPath());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fos.write(src);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(in!=null) {
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Report
0
0
Service Informatique
#2
Posted on November, 15 2019 - 10:21 AM
EDIT : Finalement le problème n'est pas lié à la taille des images, mais au faut que ce soit des jpeg, certaines images jpg ne se téléchargent pas bien (1/5ème des images), pour des raisons que je ne parvient pas à déterminer. Si je les transforme en png ou même en pdf, tout se télécharge très bien.
Auriez-vous des indices concernant les raisons du mauvais téléchargement des jpg ? Cela ne se produit que lorsque je les télécharges depuis android, si j'essaye depuis windows toutes les images jpg sonts correctement téléchargées.
Report
0
0
→ Go back to WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
WEBDEV (earlier versions)
WINDEV Mobile (earlier versions)
Reports & Queries
Off-topic
Tools
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text