We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
anandjpr
5 years agoExplorer | Level 3
Issue in getting content of PDF/Doc etc
We are consuming dropbox api from our Delphi App.
We are facing issue in getting PDF from dropbox(Upload,delete is working fine).
Getting Blank PDF
Except text file i am facing i...
- 5 years ago
Thanks! That does show the raw PDF data, indicating that the Dropbox API call itself did succeed and return the file data.
That being the case, it looks like the issue here is with writing that data to the local filesystem. As that's not related to the Dropbox API itself, I'm afraid I can't offer much help with that. You'll need to debug that part of your code, such as the "SaveToFile" method. For instance, make sure you have the right local path and that you have the permissions needed to write to that path.
Greg-DB
Dropbox Community Moderator
5 years agoWhat about the rest of the response? What's in the headers and body?
anandjpr
5 years agoExplorer | Level 3
Request Endpoint:
https://content.dropboxapi.com/2/files/download
Request header:
Authorization : Bearer <REDACTED>
Dropbox-API-Arg : {"path":"/test/BankcardHTTPS.pdf"}
Please suggest why i am getting Blank PDF file.
- anandjpr5 years agoExplorer | Level 3
I am Sharing Sample Project code .
Request you to please have a look and suggest what wrong happening there.
Sample Code:
procedure TForm6.FormCreate(Sender: TObject);
var
url:string;
lParams: TStream;
FStream: TStream;
SaveDir,TempFile:AnsiString;
MyText: TStringlist;
req:string;
response:AnsiString;
Base64: string;Input: TStringStream;
Output: TFileStream;begin
try
FStream := TStringStream.Create;
MyText:= TStringlist.create();
tryIdHTTP1.Request.CustomHeaders.Values['Dropbox-API-Arg'] :='{"path":"/test/BankcardHTTPS.pdf"}';
IdHTTP1.Request.CustomHeaders.Values['Authorization'] := 'Bearer <REDACTED>';
response:=IdHTTP1.Post('https://content.dropboxapi.com/2/files/download',FStream);MyText.Add(response);
MyText.SaveToFile('.\BankcardHTTPS.pdf');except
on E: Exception do
begin
ShowMessage('Error: ' + E.Message);
end;
end;
finally
lParams.Free;
MyText.Free;
end;
end;- anandjpr5 years agoExplorer | Level 3
Any Update.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!