Hello everyone, I am using the CMS Files api to upload a file and I have a problem. when uploading a PDF file the file manager does not recognize the content type End point: /filemanager/api/v3/files/upload
The file reaches the server through a form-data, I don't get the .PDF extension in the file.path but I get the content-type as pdf. Here show you the file.path and file.type in the server:
I show you how it looks in the file manager. I'm not getting the error, if I download the file and manually change the extension to .PDF, the file opens correctly.
@ymleyva - how do you know it's not recognizing the file type? are you getting some sort of error? Try accessing the file preview link from a non-hubspot default domain.... The default domain does some clever things like strip mime types for javascript files and HTML files... if you access the preview link of a file from your own domain, it doesn't do this
Hello, The problem happens to me with all the PDFs that I have tried. Here my server code: async sendCV(file) { let url = `https://api.hubapi.com/filemanager/api/v3/files/upload?hapikey=${hubspotConfig.APIKEY}`; let fileOptions = { access: 'PUBLIC_INDEXABLE', ttl: 'P3M', overwrite: false, duplicateValidationStrategy: 'NONE', duplicateValidationScope: 'EXACT_FOLDER' };
let formData = { file: fs.createReadStream(file.path), options: JSON.stringify(fileOptions), folderPath: "files", }; let urlFile = await new Promise((resolve, reject) => { request.post({ url: url, formData: formData }, function optionalCallback(err, httpResponse, body) { if (httpResponse) { resolve({'url': JSON.parse(body).objects[0].url}); } else reject({'status': 0, 'message': err}); }); }); }