I am using Gmail api to get hold of an attachment using node as follows :
request({
url: "https://www.googleapis.com/gmail/v1/users/xyz@gmail.com/messages/messageid/attachments/attachmentId",
method: "GET",
headers: {
Authorization: 'Bearer token'
},
json: true
}, function(error, response) {
let myData = response.body.data;
let file_data = URLSafeBase64.decode(utf8.encode(myData));
fs.writeFileSync('path/new_file.pdf', file_data);
)};
And I am able to save the same locally. I need to write file_data
to a new file and convert the same into a pdf one. I want this directly to happen in firebase storage i.e. I want to create and edit a file and change the corresponding extension as well. Is it possible ?