--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/_6MSWoyrggs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/ebfe331d-149e-4029-b95f-2171aae9a4ee%40googlegroups.com.
Change mscartel to alert
Unsubscribe: harbou...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/_6MSWoyrggs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbou...@googlegroups.com.
FUNCTION uploadPdf()LOCAL bError, cPdfFile, oHttp, cResource_URL, cResource, cPath , cFileName, nLen, ;cResponse, accessToken, nHandler, cChar, bAll, cAll# xcommand TRY => bError := errorBlock( {|oErr| break( oErr ) } ) ;;BEGIN SEQUENCE# xcommand CATCH [<!oErr!>] => errorBlock( bError ) ;;RECOVER[ USING < oErr > ] <- oErr->;;ErrorBlock( bError )SetMode( 25, 80 )Clear Screen* folder namecPath := ''* file name.cPdfFile = 'myharu.pdf'* Open a file for low-level accessIF ( nHandler := FOpen( cPath + cPdfFile ) ) == -1? 'Error de apertura de fichero:' + STR( FError() )RETURN .F.ENDIF* Get the length of the file by moving the pointer to the end.nLen := FSeek( nHandler, 0, 2 )* Reserve the space in the variable (indispensable).cAll := Space( nLen )* Move the file pointer to the beginning.Fseek( nHandler, 0 )* Read the file in cAll to the end.IF FREAD( nHandler, @cAll, nLen ) != nLen? 'Error de lectura en ' + cPdfFile + Str( FError() )FClose( nHandler )RETURN .F.ENDIF* Close file.FClose( nHandler )bAll := ''FOR EACH cChar IN cAllIF Asc( cChar ) < 32bAll += I2Bin( Asc( cChar ) )ELSEbAll += cCharENDIFNEXToHttp := Win_OleCreateObject( 'MSXML2.XMLHTTP.6.0' )IF Empty( oHttp )? 'Could no create object oHttp.'? 'Se cancela el programa.'? 'Proceso cancelado.'RETURN .F.ENDIFcResource := 'uploadIva'cResource_URL := 'https://content.dropboxapi.com/2/files/upload'accessToken := 'your_access_token'TRYcPath := '/' + cPdfFileoHttp:OPEN( "POST", cResource_URL, .F. )oHttp:setRequestHeader( "Authorization", "Bearer " + accessToken )oHttp:setRequestHeader( "Dropbox-API-Arg", '{ "path": "' + cPath + '", "mode" : "overwrite" }' )
oHttp:setRequestHeader( "Content-type", "application/octet-stream" )
oHttp:SEND( bAll )CATCH? '*** ERROR ***'? 'Controle la conexión a internet e intente de nuevo.'? 'Proceso cancelado.'RETURN .F.END? 'Getting response from appName repository. . .'* Connectivity error with the Web Service.IF oHttp:Status <> 200? '*** ERROR ***'? 'oHttp:Status = ' + AllTrim( Str( oHttp:Status ) )? oHttp:StatusText + ' Process canceled.'oHttp := NILRELEASE oHttpRETURN .F.ENDIF* I save Dropbox's reply.cResponse := oHttp:ResponseText* Name of the file according to the resource with pdf extension.cFileName := cPath + '\' + cResource* I save the answer in a file, to be able to consult it.MemoWrit( cFileName, cResponse )oHttp := NILRELEASE oHttp? 'The pdf file has been uploaded to the repository.'RETURN .T.
Thank You Sir
It Upload the File but After Uploading the file the pdf have no content in it . check this link file is complety empty .I can't understand this issue .
It's not empty, but its structure seems to be bad (under Linux):
An error occurs when opening this document. The file is damaged, and can't be repared.
It seems to be an acrobat 1.6 file.
Make a try with a simple text file ...