ディスカッション

NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Keep an eye out for upcoming NetSuite events, including meetups, workshops, and webinars. These sessions are a great way to connect with peers, learn from experts, and stay current on the latest NetSuite updates and best practices. Registration links are provided in each event.

JavaとSuiteTalkを使用してファイルキャビネットにファイルをアップロードする

編集済:Jun 2, 2025 2:48PM SuiteCloud / カスタマイズ

適用

製品:  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
タグ付けされた:

ようこそ!

サインイン

完全な詳細を表示するには、サインインしてください。

登録

アカウントがありませんか?ここをクリックして始めましょう!

リーダーボード

コミュニティの達人

第2四半期 (4月~6月 2026)

今週のリーダー

今月のリーダー

歴代リーダー