עזרה עם http put בג'אווה
אני מנסע להעלות קובץ ics לגוגל קלנדר . למרות שה URL נכון (אני מוריד ממנו את קובץ ה ics ללא בעייה)
השרת מגיב בשגיאת 404 לנסיון להעלות חזרה את הקובץ ב HTTP PUT :
try {
urlC = (HttpURLConnection) url.openConnection ();
urlC.setDoInput ( true ); // so we can get response code
urlC.setDoOutput ( true );
urlC.setUseCaches ( false );
urlC.setDefaultUseCaches ( false );
urlC.setAllowUserInteraction ( true );
urlC.setRequestMethod ( "PUT" );
urlC.setRequestProperty ( "Content-type", "text/calendar" );
urlC.setRequestProperty ( "Content-Length", "" + inputFile.length () );
// InputStream is = urlC.getInputStream ();
OutputStream os = urlC.getOutputStream ();
FileInputStream fis = new FileInputStream ( inputFile );
DataInputStream dis = new DataInputStream (
new BufferedInputStream ( fis ) );
DataOutputStream dos = new DataOutputStream ( new BufferedOutputStream os ) );
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ( ( bytesRead = dis.read ( buf ) ) != -1 ) {
dos.write ( buf, 0, bytesRead );
totalRead += bytesRead;
}
dos.flush ();
dos.close ();
urlC.disconnect ();
}catch
האם יש למישהו ניסיון ם זה ? אשמח לעזרה. חריש עמוק בגוגל לא העלה בינתיים דבר.
אני מנסע להעלות קובץ ics לגוגל קלנדר . למרות שה URL נכון (אני מוריד ממנו את קובץ ה ics ללא בעייה)
השרת מגיב בשגיאת 404 לנסיון להעלות חזרה את הקובץ ב HTTP PUT :
try {
urlC = (HttpURLConnection) url.openConnection ();
urlC.setDoInput ( true ); // so we can get response code
urlC.setDoOutput ( true );
urlC.setUseCaches ( false );
urlC.setDefaultUseCaches ( false );
urlC.setAllowUserInteraction ( true );
urlC.setRequestMethod ( "PUT" );
urlC.setRequestProperty ( "Content-type", "text/calendar" );
urlC.setRequestProperty ( "Content-Length", "" + inputFile.length () );
// InputStream is = urlC.getInputStream ();
OutputStream os = urlC.getOutputStream ();
FileInputStream fis = new FileInputStream ( inputFile );
DataInputStream dis = new DataInputStream (
new BufferedInputStream ( fis ) );
DataOutputStream dos = new DataOutputStream ( new BufferedOutputStream os ) );
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ( ( bytesRead = dis.read ( buf ) ) != -1 ) {
dos.write ( buf, 0, bytesRead );
totalRead += bytesRead;
}
dos.flush ();
dos.close ();
urlC.disconnect ();
}catch
האם יש למישהו ניסיון ם זה ? אשמח לעזרה. חריש עמוק בגוגל לא העלה בינתיים דבר.