Re: Cloud API

95 views
Skip to first unread message

Kevin Kuo

unread,
Jun 3, 2013, 3:16:12 PM6/3/13
to pdfnet-w...@googlegroups.com
Hello,

Can you share the cURL options and settings you are using?

I was able to do URL uploading with cURL on windows without any problems with the following:



My curl version (curl -V)
curl 7.23.1 (x86_64-pc-win32) libcurl/7.23.1 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS Largefile NTLM SSL libz


On Monday, June 3, 2013 3:59:39 AM UTC-7, Roi Rodríguez Sánchez wrote:
Hello,

I'm trying to use the Cloud API to upload some documents. If I post the document all work well, but I cannot use the url upload since I obtain an cURL error related to SSL.

To put an example, if I call the following URL all goes fine:
  https://api.pdftron.com/v1/document?xodEncryptPassword=123456789&fileName=ENC.pdf

When I try to upload content using the URL method, the call returns a SSL cURL Error:

  https://api.pdftron.com/v1/document?fileUrl=http%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2FDirectory%2Ffile_name.pdf&fileName=test.pdf

  RESPONSE: "null"
  cURL Error: "SSL read: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number, errno 0"

Thank you :)

Kevin Kuo

unread,
Jun 4, 2013, 4:04:33 PM6/4/13
to PDFTron WebViewer on behalf of Roi Rodríguez Sánchez
Hi Roi,

Thanks for sharing the solution. I'm glad it's working now.

Upload via file url is asynchronous (you get a response back right away, while the asynchronous process downloads and converts the document).
Demo checking appears to be done once the original file is downloaded, so demo temporarily true until then.

This behavior should probably be changed in next version, so it will always show the correct demo value.
But for now, this shouldn't affect your converted files. When conversion status is Queued or Ready, demo should be set to false.




Kevin Kuo
Software Developer
PDFTron Systems, Inc.
www.pdftron.com
Tel: 1-604-730-8989
Fax: 1-604-676-2477


CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.


P Please think before you print!



On Tue, Jun 4, 2013 at 11:35 AM, Roi Rodríguez Sánchez via PDFTron WebViewer <pdfnet-webviewer+noreply-APn2wQe...@googlegroups.com> wrote:
Hello again Kevin,

I have tried to do the upload using the command line curl, and it works:

 
* About to connect() to api.pdftron.com port 443 (#0)
*   Trying 50.112.120.165...
* connected
* Connected to api.pdftron.com (50.112.120.165) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using EDH-RSA-DES-CBC3-SHA
...
< HTTP/1.1 201 Created
          ...
< Content-Length: 206
< Date: Tue, 04 Jun 2013 17:48:44 GMT
* Connection #0 to host api.pdftron.com left intact
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><document><documentId>0354cb9187ed44bab31340b76e4c10b9</documentId><name>ENC.pdf</name><originalState>Empty</originalState><demo>true</demo></document>* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

I have made some research and realized that the error arises because of an empty POST message. I arrange the script and now it seems to work properly

curl_setopt($ch, CURLOPT_URL, $url = $apiUploadEndpoint . 'fileUrl=' . urlencode($file_url) . '&fileName=' . $file_name);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);
curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array() ); 

And now I get the file uploaded and a expected response:

{"documentId":"20bffbad283e465a96518cc171c776b0","name":"ENC.pdf","originalState":"Empty","demo":"true"}
 
PS: Why the parameter "demo" is set to true?


On Monday, June 3, 2013 11:16:10 PM UTC+2, Roi Rodríguez Sánchez wrote:
Hi Kevin,

I'm currently using a PHP script. To upload a file via POST:

$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL, 'https://api.pdftron.com/v1/document?fileName=' . $file_name);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);
curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file'=>"@$file_to_upload"));
$r = curl_exec($ch); 
 
To upload a file via URL:
 
$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL, $url = 'https://api.pdftron.com/v1/document?fileUrl=' . urlencode($file_url) . '&fileName=' . $file_name);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt($ch, CURLOPT_USERPWD, $API_KEY . ':' . $API_SECRETKEY);
curl_setopt($ch, CURLOPT_HTTPHEADER,array ("Accept: application/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true); 
$r = curl_exec($ch); 

The first piece of code works as expected, and we have used it to upload content to the Cloud API. We use the URL method because a very large file (>300MB), but besides using mostly the same code when executed curl gives an error:

SSL read: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number, errno 0

Any idea, or orientation, would be much apreciated :)

My command line curl gives this version:

$ curl -V
curl 7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz 

My phpinfo shows a coherent info with de command line curl:

curl

cURL support => enabled
cURL Information => 7.24.0
Age => 3
Features
AsynchDNS => Yes
Debug => No
GSS-Negotiate => Yes
IDN => No
IPv6 => Yes
Largefile => Yes
NTLM => Yes
SPNEGO => No
SSL => Yes
SSPI => No
krb4 => No
libz => Yes
CharConv => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin12.0
SSL Version => OpenSSL/0.9.8r
ZLib Version => 1.2.5

--
You received this message because you are subscribed to the Google Groups "PDFTron WebViewer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfnet-webview...@googlegroups.com.
To post to this group, send email to pdfnet-w...@googlegroups.com.
Visit this group at http://groups.google.com/group/pdfnet-webviewer?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages