question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error thrown when uploading assets

See original GitHub issue

Hi,

I have successfully deployed the app to my server, and many thanks to the great work from you. However, after the upload process completed, server will throw error as followed and failed to save/serve the uploaded file:

Sending 500 ("Server Error") response:
 Error: ENOENT: no such file or directory, open '7b956cf1-9406-4530-92c4-e46e241becfb.zip'

I have tried updated the dirname in local.js and ensured that directory has correct permission for user (in fact, I even tried 0777), but still no luck on this.

It seems the file is not getting stored anywhere, could you please help with this issue and provide more information about the assets storage progress?

Many thanks to you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
sergio-carocommented, Apr 12, 2020

I have to say that neither @oozliuoo solution nor @nellyLidanYang solution worked for me, but a combination of both methods.

Just in case someone is in the same situation as me, this is what I did:

  1. Changes made to config/local.js:
    • I made a combination of both solutions: Renaming the key dirname to __dirname and setting the location of the dir to be ./.
  files: {
    // Folder must exist and user running the server must have adequate perms
    __dirname: './',
    // Maximum allowed file size in bytes
    // Defaults to 500MB
    // maxBytes: 524288000
  }
  1. Changes made to api/controllers/AssetController.js:
  • The solution provided by @oozliuoo works, but just only for uploading files to the server. Manually downloading files, with this config/mods, will not work (I did not try apps’ updates though, so I don’t know if it works). Modification of .getHash() calls to add the temp folder.
if (fileExt === '.nupkg') {
    // Calculate the hash of the file, as it is necessary for windows
    // files
    hashPromise = AssetService.getHash(`.tmp/uploads/${uploadedFile.fd}`);
} else if (fileExt === '.exe' || fileExt === '.zip') {
    hashPromise = AssetService.getHash(`.tmp/uploads/${uploadedFile.fd}`, 'sha256');
} else {
    hashPromise = Promise.resolve('');
}
  • Second, to allow users to manually download files, I made a small modification bellow that previous code. Changes to fd attr to be similar to the previous change.
hashPromise
    .then(function(fileHash) {
        // Create new instance of model using data from params
        Asset
           .create(_.merge({
              name: uploadedFile.filename,
              hash: fileHash,
              filetype: fileExt,
              fd: `.tmp/uploads/${uploadedFile.fd}`,
              size: uploadedFile.size
   }, data))
4reactions
nellyLidanYangcommented, Apr 15, 2019

try set"dirname" to __dirname. I fixed mine with that

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot asset upload errors - Ads Creative Studio Help
Check that the file you're trying to upload uses a supported asset type. If it's not supported, try uploading a different asset. You...
Read more >
Error Uploading Assets - Craft CMS Stack Exchange
We're receiving the following error when uploading Assets: Upload failed for Michael-Mabry-COO-MOOYAH-executive.png. The error message was: “Error uploading the ...
Read more >
Asset uploading-error | SAP Community
I am doing asset uploading throw BDC. In Excel sheet there is GROUP ASSET coloum is there. I have one doubt. Which particular...
Read more >
[CMS-6360] IE8: when uploading a document to assets an JS error ...
When uploading a document to a folder in Assets in ie8 a javascript error is thrown. It has to do with a generated...
Read more >
Receiving error in Anypoint Exchange "The uploaded file does ...
You are getting the error "The uploaded file does not have a valid OAS format" while uploading OAS assets to Exchange. User-added image ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found