How to decode responses - paw-app

I have API calls that return files that are gzipped and then base64 encoded so that they can be returned as part of JSON responses. I'd like to be able to decode those files. At the moment I have to copy the base64 test, decode it and then gunzip the result.
Is there an extension for this or can I create one?

copy response text
go to header or params or body tab
paste copied text any value field
select all pasted text
mouse right-click -> encoding -> URL-encoding/Base64 -> encode/decode
paste text to input field
or use Atom + escape-utils plugin

Related

How to submit form files on Paw?

I would like to use Paw to send form files, that I can catch from my PHP script with the $_FILES global variable.
The File body option sends a file, but it is not encapsulated in a form structure and PHP cannot treat it.
How can I do that ?
Set your request to POST, which is likely to be the method you want to use
Go to the body tab, and pick Multipart on the left column
Enter the expected file name as "Part Name" (the key you want to get in your PHP $_FILES global)
In the Value field of the Multipart editor, right-click and pick File > File Content
Click on the File token, and you'll be able to pick or drag-and-drop a file
Press Cmd + R (or Cmd + Enter) to send the request!

How to URL encode a long text?

how can I enter a 2KB formatted TXT (line breaks) that should get URL-Encoded? Just pasting it into the input line doesn't work as the result is not formatted in any way.
https://www.dropbox.com/s/z934uvy6bjz98e3/Screenshot%202016-04-13%2014.28.16.PNG?dl=0
If you have a really complex text, I recommend you to just keep the text in a plain text file somewhere in your disk, and use a File Dynamic Value to reference it, and wrap the whole thing in your URL-Encode Dynamic Value.
Some steps:
Create a file with your content
In your URL-Encode dynamic value, right-click on the Input field and pick File > File Content
Click on the newly created File (Not specified) token, and you'll be prompted to either pick or drag-and-drop a file
You should be good to go. And whenever the file changes, you can send the request, and it should be up-to-date, it's just a pointer to the file.
If you use proper URL encoding, the linebreaks \n should be encoded as %0A. This
foo
bar
baz
will be encoded as
foo%0Abar%0Abaz%0A

other ways to transfer PDF Byte as a HttpResponseMessage?

I have a function that retrieves PDF bytes from another Webservice. What I wanted to do is make the PDF bytes also available to others by creating an API call that returns HttpResponseMessage.
Now, my problem is I don't think that passing it through json is possible, because it converts the PDF bytes into a string?
Is there any other practical way of passing the PDF, or making the PDF visible to the requestors?
(Note: saving the PDF file in a specific folder and then returning the URL is prohibited in this specific situation)
I just solved it. There is a new paramater responseType: 'arrayBuffer' which addresses this problem. Sample: $http.post('/api/konto/setReport/pdf', $scope.konta, { responseType: 'arraybuffer' }) View my question and answer on SO: How to display a server side generated PDF stream in javascript sent via HttpMessageResponse Content

convert uploaded file stream into string

I want to use UploadedTextFile.FileContent to read file's content and save it as string . but it returns a set of encoding-like characters . this is the code :
string content = (new streamReader(UploadedTextFile.FileContent,true)).ReadToEnd();
but the result is something like this
yua%^##568sda_sdf89 ....
file content is not english .
Microsoft Word documents have tons of formatting content in there as well. Try opening a .doc file in Notepad. What you see there is what you're going to get, regardless of encoding.
If you still want to try and extract the content from the document, there are tools in C# to help you out. I recommend reading the answer in this link

How can I return a pdf from a web request in ASP.NET?

Simply put, I'd like someone to be able to click a link, and get a one-time-use pdf. We have the library to create PDF files, so that's not an issue.
We could generate a link to an aspx page, have that page generate the pdf, save the pdf to the filesystem, and then Response.Redirect to the saved pdf. Then we'd somehow have to keep track of and clean up the PDF file.
Since we don't ever need to keep this data, what I'd like to do instead, if possible, is to have the aspx page generate the pdf, and serve it directly back as a response to the original request. Is this possible?
(In our case, we're using C#, and we want to serve a pdf back, but it seems like any solution would probably work for various .NET languages and returned filetypes.)
Assuming you can get a byte[] representing your PDF:
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition",
"attachment;filename=\"FileName.pdf\"");
Response.BinaryWrite(yourPdfAsByteArray);
Response.Flush();
Response.End();
Look at how HTTP works. The client (=browser) doesn't rely on extensions, it only wants the server to return some metadata along with the document.
Metadata can be added with Response.AddHeader, and one 'metadata line' consists of Name and Value.
Content-Type is the property you are interested in, and the value is MIME type of the data (study: RFC1945 for HTTP headers, google for MIME type).
For ordinal aspx pages (html, ....) the property is 'text/html' (not so trivial, but for this example it is enough.). If you return JPG image, it can have name 'image.gif', but as long as you send 'image/jpeg' in Content-Type, it is processed as JPG image.
Content-type for pdf is 'application/pdf'.
The browser will act according to default behaviour, for example, with Adobe plugin, it will display the PDF in it's window, if you don't have any plugin for PDF, it should download the file, etc..
Content-Disposition header says, what you should do with the data. If you want explicitly the client to 'download' some HTML/PDF/whatever, and not display it by default, value 'attachment' is what you want. It should have another parameter, (as suggested by Justin Niessner), which is used in case of something like:
http://server/download.aspx?file=11 -> Content-Disposition: attachment;filename=file.jpg says, how the file should be by default named.

Resources