What is the 2.X equivalent to response.setContentT...
# suitescript
t
What is the 2.X equivalent to response.setContentType in suitelets ? I want to replicate this line
response.setContentType('PDF','ABC.pdf','INLINE')
b
theoretically ServerResponse.setHeader if you want to manipulate the actual header
t
Ahh, fortunately I found the same. How can give name to my file battk ?
b
t
I am already giving it in the fileobject as “TESTPDFFILE.PDF”
But it’s still appearing as scriptlet.
Right now it’s scriptlet.nl
b
not sure whats that screenshot is referring to
nor do i know what your code looks like
t
var pdffile = file.create({
name: 'TESTPDFFILE.PDF',
fileType: file.Type.PDF ,
contents: signDoc
});
log.debug({
title: 'signDoc',
details: signDoc
});
context.response.setHeader({
name: 'Content-Type',
value: 'application/pdf'
})
context.response.writeFile({
file: pdffile,
isInline: true
});
b
is it an actual valid pdf?
its not normal to create a pdf file using file.create
t
Yes.
I am getting a base64 response from an API. and I am directly putting that to file object
It is working fine
I want to use this filename header battk.
How do I input another header to this setHeader thing, it’s accepting only one.
b
you would use setHeader multiple times
t
nah, that isn’t working man
context.response.setHeader({
name: 'Content-Disposition',
value: 'inline; filename="Test PDF.pdf"'
});
b
whats the actual header received?
t
received from where?
b
use your browser's developer tools
there should be a network tab that logs request and responses
including headers