FOROS PROFESIONALES
WINDEV
,
WEBDEV
y
WINDEV Mobile
Inicio
|
Mensajes recientes
|
Conéctese...
|
Desconectar
|
Español
Inicio
→
WINDEV Mobile 2024
→
large (resumable) file upload using onedrive/graph api
large (resumable) file upload using onedrive/graph api
Iniciado por Mike Stewart, 20,feb. 2017 12:57 - 2 respuestas
Conéctese…
Mike Stewart
#1
Publicado el 20,febrero 2017 - 12:57
I have managed to get all of the required communications for the graph api to do most things but the large file upload I am struggling with this one.
This is the example that I am trying to recreate for each portion of the file
PUT https://tenant-my.sharepoint.com/alkjl1kjklna
Content-Length: 26
Content-Range: bytes 0-25/128
<bytes 0-25 of the file>
here is the code I am using to try and achieve this
s
Compl
is string
=
"N"
n
SoFar
is int
=
0
n
Piece
is int
=
1
//splitting the file into sections which are divisible by 320kiB
n
SixBit
is
8
byte int
=
1966080
n
Attempts
is int
=
1
n
Tot
is
8
byte int
=
fSize
(
s
Ad
)
n
Files
is int
=
fSplit
(
s
Ad
,
n
SixBit
,
"splitFile"
)
i
=
1
WHILE
s
Compl
=
"N"
AND
n
Attempts
<
=
5
s
F
is string
=
i
IF
i
>
9
THEN
s
F
=
"splitFile.0"
+
s
F
ELSE
s
F
=
"splitFile.00"
+
s
F
END
HTTPCreateForm
(
"piecemeal"
)
s
Tot
is
string
=
fSize
(
s
F
)
n
ThisPieceSize
is int
=
fSize
(
s
F
)
//HTTPAddParameter("piecemeal","Content-Length",sTot)
s
ContRan
is string
=
"bytes%20"
+
n
SoFar
+
"-"
+
(
n
SoFar
+
n
ThisPieceSize
-
1
)
+
"/"
+
n
Tot
//HTTPAddParameter("piecemeal","Content-Range",sContRan)
buf
ThisOne
is
Buffer
=
fLoadBuffer
(
s
F
)
s
Buf
is ANSI string
=
buf
ThisOne
s
Final
is ANSI string
=
StringBuild
(
"Content-Length: %1"
+
CR
+
"Content-Range: %2"
+
CR
+
CR
+
"%3"
,
s
Tot
,
s
ContRan
,
s
Buf
)
s
UploadURL
=
s
UploadURL
+
"&Content-Length="
+
s
Tot
+
"&Content-Range="
+
s
ContRan
IF
HTTPSendForm
(
"piecemeal"
,
s
UploadURL
,
httpPut
,
"Mozilla/4.0 (compatible; MSIE 4.01 - Windows CE)"
,
s
Buf
,
"text/plain"
) =
True
THEN
buf
ResHTTP
=
HTTPGetResult
(
httpResult
)
IF
IniOSMode
(
) =
True
OR
IniOSSimulatorMode
(
) =
True
OR
IniOSEmulatorMode
(
) =
True
THEN
IF
StringCount
(
buf
ResHTTP
, “
ISO
-
8859
-
1
”
,
IgnoreCase
) =
0
THEN
s
HTTPRes
=
UTF8ToString
(
buf
ResHTTP
)
ELSE
s
HTTPRes
=
AnsiToUnicode
(
buf
ResHTTP
)
END
ELSE IF
InAndroidMode
(
) =
True
OR
InAndroidSimulatorMode
(
) =
True
OR
InAndroidEmulatorMode
(
) =
True
// result in Android
s
HTTPRes
=
UTF8ToString
(
buf
ResHTTP
)
END
s
Head
= (
HTTPGetResult
(
httpHeader
)
)
//
EDT_NoName1=sHTTPRes
IF
Contains
(
s
Head
,
"HTTP/1.1 202 Accepted"
)
=
True
THEN
n
SoFar
=
n
SoFar
+
n
ThisPieceSize
n
Attempts
=
1
IF
i
=
n
Files
THEN
s
Compl
=
"Y"
END
ELSE
n
Attempts
+
+
END
ELSE
Error
(
ErrorInfo
(
errMessage
)
)
END
i
+
+
END
When I try to put the parameters in via httpAddParameter then I get 400 errors (badly formed request)
When I create a single string with all of the parameters (including the file piece) then the sendForm is failing.
Any suggestions are greatly welcomed.
Mike
Informar
0
0
Mike Stewart
#2
Publicado el 21,febrero 2017 - 10:01
Well progress is being made using the following couple of lines
// using split file I create the necessary fragments
nFiles is int = fSplit(sAd,nSixBit,"splitFile")
// These are then attached to the form using httpAddFile
sFinal is ANSI string = StringBuild("Content-Length: %1"+CR+"Content-Range: %2"+CR+CR,sTot,sContRan)
HTTPAddFile("piecemeal",sFinal,sF,"application/x-www-form-urlencoded")
This is now producing a file of the right size and name at the other end but this file (a moviefile for testing purposes) doesn't play. I am looking to transfer zip files that will contain images as well as data. So obviously the integrity of that data is vital.
I am now looking at whether there are missing pieces where the data did not quite all transfer or if the 'format' of the data transfer (plain/text... urencoded etc makes any difference.
Again though any suggestions welcome
Informar
0
0
Mike Stewart
#3
Publicado el 23,febrero 2017 - 10:00
Add the file buffer as a parameter with no heading (instead of using httpaddfile)
Send the form using the application/xml to sort out the boundaries.
Done
Informar
0
0
→ Volver a WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (versiones precedentes)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Búsqueda Tipo
Sólo temas
Todos los mensajes
Periodo Buscar
Cualquier fecha
Última hora
Última 24 horas
Última semana
Último mes
Último año
Cancelar
Vista previa del mensaje
Añadiendo una imagen
Importar una imagen desde una URL
Enviar una imagen desde un archivo de su disco
Arrastrar un archivo o click en "Examinar..."
o
Cancelar
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Texto