client-javascript icon indicating copy to clipboard operation
client-javascript copied to clipboard

Is the file upload still working?

Open schrufygroovy opened this issue 5 years ago • 3 comments

I am experiencing issues with file uploads. Even the example from: https://github.com/reportportal/client-javascript/blob/master/examples/generateTestLaunch.js is not working. The headers are still set and sent, but it seems that ReportPortal is ignoring them.

When one checks the documentation: https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/reporting.md#batch-save-logs it's stated, that all files should be uploaded at once.

Also the content type "multipart/form-data" which is used in JavaScript implementation is not mentioned in the example

schrufygroovy avatar Mar 30 '20 14:03 schrufygroovy

@KatsiarynaTatarynovich could you please check this issue?

evjlobanova avatar Apr 02 '20 14:04 evjlobanova

@AmsterGet @KatsiarynaTatarynovich @evjlobanova could someone just provide an working example for the JavaScript client? I finally got it working with following:

      const fsObject = fs.readFileSync(diffImageAbsolutePath);
      const contentBase64 = new Buffer(fsObject).toString('base64');
      const fileObject = {
        name: 'testPair.diffImage.png',
        type: 'image/png',
        content: contentBase64,
      };
      var sendLogObject = reportPortalClient.sendLog(
        testObject.tempId,
        {
          level: 'ERROR',
          message: 'Difference found',
        },
        fileObject);

schrufygroovy avatar Jul 20 '20 14:07 schrufygroovy

Hi @schrufygroovy Check out the following example for the agent-js-mocha - https://github.com/reportportal/examples-js/blob/master/example-mocha/spec/logTest.spec.js#L80 It uses the sendLog method from the client-javascript instance.

Thanks for finding. It would be nice to mention this in the docs.

AmsterGet avatar Jul 20 '20 16:07 AmsterGet