13 messaggi dal 27 settembre 2006
Ok.. ragazzi nessun problema ho risolto ho trovato.... grazie a tutti per l'aiuto... fatemi sapere se volete che pubblichi il codice che magari può servire a qualcuno...


grazie ancora
16 messaggi dal 24 agosto 2005
si grazie posta il codice......

io ho un problema a "postare" un file con Httpwebrequest, DALL'ALTRA PARTE MI ARRIVAS EMPRE VUOTO
13 messaggi dal 27 settembre 2006
dim length as integer = 0
dim boundary as string = "---------------------------" & DateTime.Now.Ticks

dim richiesta as httpwebrequest = httpwebrequest.create(linkviddler)
richiesta.contentType = "multipart/form-data; boundary=" & boundary
richiesta.method = "POST"
richiesta.Keepalive = true

dim memstream as new System.IO.MemoryStream


'method
dim boundarybytes as byte() = Encoding.ASCII.GetBytes(vbCrLf & boundary.tostring() & vbCrLf)

dim formitema as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""method""; " & vbCrLf & vbCrLf & "viddler.videos.upload"

dim formitemsbytes as byte() = Encoding.UTF8.GetBytes(formitema)
memstream.Write(formitemsbytes, 0, formitemsbytes.Length)

'Apikey
dim apikeystring as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""api_key""; " & vbCrLf & vbCrLf & apikey

dim apikeystringbytes as byte() = Encoding.UTF8.GetBytes(apikeystring)

memstream.Write(apikeystringbytes, 0, apikeystringbytes.Length)

'session id
dim sessionidstring as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""sessionid""; " & vbCrLf & vbCrLf & testo.text

dim sessionidstringbytes as byte() = Encoding.UTF8.GetBytes(sessionidstring)

memstream.Write(sessionidstringbytes, 0, sessionidstringbytes.Length)


'titkle

dim titlestring as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""title""; " & vbCrLf & vbCrLf & "titolo del video"

dim titlestringbytes as byte() = Encoding.UTF8.GetBytes(titlestring)

memstream.Write(titlestringbytes, 0, titlestringbytes.Length)

'tags

dim tagsString as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""tags""; " & vbCrLf & vbCrLf & "tags"

dim tagsStringbytes as byte() = Encoding.UTF8.GetBytes(tagsString)

memstream.Write(tagsStringbytes, 0, tagsStringbytes.Length)

'description

dim descrizioneString as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""description""; " & vbCrLf & vbCrLf & "descrizione del video"

dim descrizioneStringbytes as byte() = Encoding.UTF8.GetBytes(descrizioneString)

memstream.Write(descrizioneStringbytes, 0, descrizioneStringbytes.Length)



'makepublic


dim pubblico as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""make_public""; " & vbCrLf & vbCrLf & "0"

dim pubblicobytes as byte() = Encoding.UTF8.GetBytes(pubblico)

memstream.Write(pubblicobytes, 0, pubblicobytes.Length)



'file


dim fileName as string = vbCrLf & "--" & boundary & vbCrLf & "Content-Disposition: form-data; name=""file""; filename=""" & fileform.postedFile.filename & """" & vbCrLf & "Content-Type: "& fileform.postedFile.ContentType & vbCrLf & vbCrLf
dim fileNamebytes as byte() = Encoding.UTF8.GetBytes(fileName)

memstream.Write(fileNamebytes, 0, fileNamebytes.Length)


'Dim objBinReader As New BinaryReader(File.OpenRead(server.MapPath("lozivi84_4.flv")))
Dim objBinReader As New BinaryReader(fileform.postedFile.InputStream)
Dim bytPhotoContents As Byte() = objBinReader.ReadBytes(objBinReader.BaseStream.Length)
objBinReader.Close()

memstream.write(bytPhotoContents,0, bytPhotoContents.length)


'chiusura
dim footer as string = vbCrLf & "--" & boundary & "--"

dim footerbytes as byte() = Encoding.UTF8.GetBytes(footer)

memstream.Write(footerbytes, 0, footerbytes.Length)

richiesta.ContentLength = memstream.Length


dim requestStream as stream = richiesta.GetRequestStream()

memStream.Position = 0

dim tempBuffer as byte()
redim tempBuffer((memStream.length)-1)


memStream.Read(tempBuffer,0,tempBuffer.Length)
memStream.Close()
' byte[] tempBuffer = new byte[memStream.Length];

requestStream.Write(tempBuffer,0,tempBuffer.Length)
requestStream.Close()

dim webResponse2 as webresponse = richiesta.GetResponse()

dim stream2 as stream = webResponse2.GetResponseStream()
dim reader2 as new streamreader(stream2)

dim risposta as string = reader2.ReadToEnd
webResponse2.Close()
16 messaggi dal 24 agosto 2005
MI-TI-CO ora va una spada... mi rimane solo da fare la traduzione in c#
13 messaggi dal 27 settembre 2006
se vuoi facilitarti la vita usa questo tool...

http://www.developerfusion.com/tools/convert/vb-to-csharp/

ciao ciao

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.