No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. aquinch
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Best 0
    • Groups 0

    aquinch

    @aquinch

    -1
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    aquinch Follow

    Latest posts made by aquinch

    • Test q-select with Cypress

      Hi,

      How do I test that a q-select is readonly with Cypress and Quasar?

      posted in Framework
      A
      aquinch
    • RE: File upload to Laravel

      I don’t get any errors, but Laravel tells me that the lx02 param is being passed as a String instead of a file object:

            const stream = fs.createReadStream('C:/Users/Ingo/Downloads/LX02_805_2020726_94611.xlsx')
            stream.on('error', err => console.log(err))
            data.append('lx02', stream)
      
      posted in Help
      A
      aquinch
    • RE: File upload to Laravel

      @dobbel , I don’t think the issue is on the request but on electron’s access to the file system through the fs library.

      posted in Help
      A
      aquinch
    • RE: File upload to Laravel

      I’ve got it working by using Quasar’s file picker instead of the fs.createReadStream, so that seems to be the issue. But I can’t figure out why it’s not working:

      <template>
        <div class="q-pa-md q-gutter-sm">
          <q-btn color="purple" label="IW73" @click='runIW73' />
          <q-btn color="primary" label="LX02" @click='runLX02' />
          <q-file v-model="model" label="Standard" />
          <q-btn color="primary" label="LX02 Upload" @click='lx02Upload' />
        </div>
      </template>
      
      <script>
      import { rpa } from 'src/scripts/rpa'
      import FormData from 'form-data'
      const fs = require('fs')
      
      export default {
        name: 'tfmch_updates',
        data () {
          return {
            model: null
          }
        },
        methods: {
          runIW73 () {
            console.log('Running test.py')
            rpa.sap_IW73()
          },
          runLX02 () {
            console.log('Running LX02')
            rpa.sap_LX02()
          },
          lx02Upload () {
            console.log('LX02 Upload')
            const data = new FormData()
            data.append('truncate', 'true')
            data.append('lx02', fs.createReadStream('C:/Users/Ingo/Downloads/LX02_805_2020726_94611.xlsx')) // <- NOT WORKING
            const config = {
              method: 'post',
              url: 'http://localhost/tfmch_LARAVEL/public/api/import/lx02',
              headers: { 'Content-Type': 'multipart/form-data' },
              data: data
            }
            this.$axios(config)
              .then((response) => {
                console.log(JSON.stringify(response.data))
              })
              .catch((error) => {
                console.log(error)
              })
          }
        }
      }
      
      </script>
      
      posted in Help
      A
      aquinch
    • RE: File upload to Laravel

      @dobbel, I’ve tried with plain javascript XHR and it also doesn’t work. I’ve used form-data on both tests, so there could be something there.

      posted in Help
      A
      aquinch
    • RE: File upload to Laravel

      @metalsadman, thanks for the comment but not very helpful though. I have already done that and that’s why I’m posting a question here. I can’t seem to see the diference from the example you’ve posted to mine - although I would assume there could be one hence the help request.

      posted in Help
      A
      aquinch
    • File upload to Laravel

      I want to post an excel file which is on my local drive into a Laravel app. I have tested the Laravel API through Postman and even through excel’s vbs script. So the API doesn’t seem to be the issue. But through Quasar all I get is a Not Updated response from Laravel. I’ve seen a couple of similar queries on this forum where people are having issues with multi-part forms and Quasar, and no answers to those queries. Seems a like a trend…?

      Here is my Javascript file:

      import Pusher from 'pusher-js'
      import { PythonShell } from 'python-shell'
      import axios from 'axios'
      const FormData = require('form-data')
      const fs = require('fs')
      const path = require('path')
      
      const options = {
        // mode: 'text',
        // pythonPath: 'path/to/python',
        // pythonOptions: ['-u'], // get print results in real-time
        scriptPath: path.join(__dirname, '/../rpa')
        // args: ['value1', 'value2', 'value3']
      }
      
      const exportDir = 'C:\\TEMP\\TFMCH\\'
      
      export const rpa = {
      tfmch_LX02 (warehouse, filePath, truncate) {
          console.log('Updating LX02 on TFMCH')
          const URL = 'http://localhost/tfmch_LARAVEL/public/api/' + 'rpa/lx02'
          const formData = new FormData()
          formData.append('lx02', fs.createReadStream(filePath))
          formData.append('truncate', truncate)
          const formConfig = {
            headers: { 'Content-Type': 'multipart/form-data' }
          }
          console.log(URL)
          console.log(fs.createReadStream(filePath))
          // console.log(filePath)
          // console.log(formData)
          // console.log(formConfig)
      
          axios.post(URL, formData, formConfig)
            .then((response) => {
              console.log(response.data)
              // if (warehouse === 805) {
              //   rpa.sap_LX02_wh(804, false)
              // }
            })
            .catch((e) => {
              console.log(e)
              // console.log('error')
            })
        }
      }
      

      And this is my Laravel API:

      // import lx02
      Route::post('import/lx02', function(Request $request){
      
          ini_set('max_execution_time', 300);
      
          // dd($request->lx02);
          // return response()->json($request->lx02); 
      
          if($request->hasFile('lx02')){
      
              if ($request->truncate) {
                  LX02::query()->truncate();
              }
              
              Excel::import(new LX02Import, request()->file('lx02'));
              
              $config = new Upload;
              $config->table_name = 'LX02';
              $config->save();
      
              // $deletedRows = lx02::where('sloc', 'LIKE', 'S%')->delete();
      
              return response()->json("Updated"); 
          }
          return response()->json("Not Updated"); 
      });
      
      posted in Help
      A
      aquinch