ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
JavaとSuiteTalkを使用してファイルキャビネットにファイルをアップロードする
適用
製品: NetSuite 2020.1
シナリオ
ユーザーは、JavaとSuitetalkを使用して、ローカルファイルを自分のNetsuiteアカウントのファイルキャビネットにアップロードしたいと考えています。
解決策
このサンプルコードは、その方法を示しています。
注:このコードはサンプリングのみを目的としています。
public void uploadFile() { try { String filePath = "C:\\Documents and Settings\\bsicam\\My Documents\\My Pictures\\testPDF.pdf"; java.io.File localFile = new java.io.File(filePath); byte []buffer = new byte[4096]; ByteArrayOutputStream ous = new ByteArrayOutputStream(); InputStream ios = new FileInputStream(localFile); int read = 0; while ( (read = ios.read(buffer)) != -1 ) { ous.write(buffer, 0, read); } if(ous != null) { ous.close(); } ios.close(); byte[] byteArray = ous.toByteArray(); File newFile = new File(); newFile.setContent(byteArray); newFile.setName("testPDF.pdf"); newFile.setEncoding(FileEncoding._utf8); newFile.setAttachFrom(FileAttachFrom._computer); newFile.setFileType(MediaType._PDF); newFile.setFolder(new RecordRef("", "-4", "", RecordType.folder)); WriteResponse uploadResponse = port.add(newFile); if
タグ付けされた:
0