netsuitephp / netsuite-php

NetSuite PHP API Client with namespaces and autoloading
Other
189 stars 85 forks source link

File upload creates a file with empty content #148

Closed Sml995 closed 1 year ago

Sml995 commented 1 year ago

Describe the bug The file uploaded to the file cabinet are empty

How To Reproduce

$file = new File();

$file->folder = new RecordRef();
$file->folder->internalId = XXX;

$file->name = 'filename.png';
$file->fileType = MediaType::_PNGIMAGE;
$file->attachFrom = FileAttachFrom::_computer;

$content = base64_encode(file_get_contents($request->file('file')));
// Outputs a base64 string that can be converted back to an image using any base64=>image tool
$file->content = $content;

$request = new AddRequest();
$request->record = $file;

$addResponse = NetSuite::add($request); // SUCCESS

The request almost works as the file is created, in the right folder, BUT the content is unreadable

Expected behavior The file content should be displayed

Additional context Also asked on SO

jrebs commented 1 year ago

Keeping in mind that this package is simply a different way of distributing NetSuite's own PHP toolkit which wrap the SOAP calls, it appears to me that the package is working correctly, as you're getting successful responses from NetSuite. I haven't worked with file uploads at all, so I can't offer any useful suggestions on things to try, but there's not really any indication to me that this is an issue with this distribution and is either an issue with the usage or the input or something. If you can produce something that clearly demonstrates the issue is specific to the netsuite-php package itself, then you can re-submit the issue with the findings that demonstrate this. In the meantime, stack overflow and our own Discussions section (link up top) would be the appropriate places to look for help.