Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Can't upload files when running in a subdir

Open Huljo opened this issue 10 years ago • 16 comments

Rocket.Chat version: 0.43.0

I attempt to run Rocket.chat in a subfolder and my ROOT_URL is http://mydomain.com/chat . During a new file upload, a request to http://mydomain.com/ufs/rocketchat_uploads/bpbPdJqJKvSZu6Tr7?token=9bC8e9c938&progress=1 is sent. This request URL is not prefixed by the subfolder /chat.

Huljo avatar Nov 02 '16 16:11 Huljo

try setting Administration -> General -> CDN Prefix to "/chat"

AlecTroemel avatar Nov 02 '16 16:11 AlecTroemel

Thanks @AlecTroemel but my CDN_PREFIX is already set with my subfolder name, I still can't upload files. I can't find where this URL ufs/rocketchat_uploads is defined.

Huljo avatar Nov 02 '16 22:11 Huljo

hmm. if you manually add your subdir like http://mydomain.com/ufs/rocketchat_uploads/bpbPdJqJKvSZu6Tr7?token=9bC8e9c938&progress=1 does it find the file correctly? I'm running rocketchat 0.45 in a subdir without any issues. Also, what storage type are you using?

AlecTroemel avatar Nov 03 '16 15:11 AlecTroemel

I tried to send a POST request to http://mydomain.com/chat/ufs/rocketchat_uploads/, the server return 400. I guess the route is the right one but there is no request data.

Huljo avatar Nov 04 '16 13:11 Huljo

Hello. I have exactly the same issue. From the development console : Failed to load resource: the server responded with a status of 404 (Not Found). https://my.domain.com/ufs/rocketchat_uploads/aSvtsqvReYYHZwwwP?token=5AE938cb88&progress=0.44993683748009006 Actually I run in a subfolder https://my.domain.com/subfolder and I set my CDN with /subfolder. @Huljo since the 4th novembre did you find a solution?

julienkoziel avatar Dec 13 '16 14:12 julienkoziel

Hi @julienkoziel Nope, didn't find the solution. I'll take a look again soon.

Huljo avatar Dec 13 '16 15:12 Huljo

So I found that the URL is used here, defined here and here.

By adding

UploadFS.config.storesPath = (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX.substring(1))+'/ufs';

to lib/fileUpload.coffee, the client request is sent well but the webapp handler is not catching the request.

Issue created on jalik-ufs repository.

Huljo avatar Dec 29 '16 15:12 Huljo

I have exactly the same issue. @Huljo can you share your solution ? Thanks a lot

mattlin avatar Jan 23 '17 06:01 mattlin

Your Rocket.Chat version:0.50.1 The issue is not fixed yet. Hope it will be fixed soon :P

mattlin avatar Jan 25 '17 03:01 mattlin

Hi @mattlin, I've created an issue on Jalik-ufs repository and I'm waiting for their reply. Take a look at my last comment in here : #271567995 to get more details.

Huljo avatar Jan 26 '17 19:01 Huljo

@Huljo Thank you very much

mattlin avatar Feb 08 '17 06:02 mattlin

The issue still unresolved in v.0.54.2.

Chat is configured to work with http://domain.com/chat URL

On client side there is a post request to the root directory without subfolder:

http://domain.com/ufs/fileSystem/wxuqjpkHyxLdNM9Xy?token=a829CAD9c8&progress=0.1751362907536077

In server log it fails with the following error:

Exception while invoking method 'ufsComplete' Error: ENOENT: no such file or directory, open '/tmp/ufs/wxuqjpkHyxLdNM9Xy'
  at Object.Future.wait (/path-to-rocket-chat/programs/server/node_modules/fibers/future.js:449:15)
  at [object Object].Meteor.methods.ufsComplete (/path-to-rocket-chat/programs/server/packages/jalik_ufs.js:824:24)
  at [object Object].methodsMap.(anonymous function) (/path-to-rocket-chat/programs/server/packages/rocketchat_lib.js:1095:26)
  at maybeAuditArgumentChecks (/path-to-rocket-chat/programs/server/packages/ddp-server.js:1817:12)
  at /path-to-rocket-chat/programs/server/packages/ddp-server.js:905:20
  at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
  at /path-to-rocket-chat/programs/server/packages/ddp-server.js:904:41
  at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
  at /path-to-rocket-chat/programs/server/packages/ddp-server.js:903:46
  at [object Object]._.extend.protocol_handlers.method (/path-to-rocket-chat/programs/server/packages/ddp-server.js:876:21)
  at /path-to-rocket-chat/programs/server/packages/ddp-server.js:755:85

    - - - - -
  at Error (native)

AlexTr avatar Mar 30 '17 09:03 AlexTr

One mode issue with Rocket.Chat installation in subfolder is that redirect URL from OAuth custom module (actually it's is my module based on build-in rocketchat-oauth-custom module) isn't correct. Instead of the following:

http://domain.com/chat/_oauth

it generates this one:

http://domain.com/_oauth/chat

AlexTr avatar Mar 30 '17 11:03 AlexTr

I'm running v.0.55.1 in a docker container and have the same problem with subfolder and file upload. First thought it is a problem on the docker image and posted it here (https://github.com/RocketChat/Docker.Official.Image/issues/30). But then saw this issue. Is there a statement if and when it will be fixed?

bschueller avatar Apr 28 '17 07:04 bschueller

I have exactly the same issue running rocket.chat in Docker: OS: Ubuntu 16.04 rocket.chat version: 0.57.2

If I set ROOT_URL to http://localhost:8080/chat everything works perfectly fine except a the file upload. Checking the developer console on my browser I get the following error when trying to upload a file:

Request URL:http://localhost:8080/ufs/GridFS:Uploads/ByuAbT4u4NC69woyd?token=0AfaEA996b&progress=1
Request Method:POST
Status Code:404 Not Found
Remote Address:[::1]:8080

lukasredev avatar Jul 23 '17 14:07 lukasredev

@rocket-cat close I'm closing this due to lack of activity Please test on the latest version of Rocket.Chat before reopening or creating a new issue.

reetp avatar Oct 29 '18 16:10 reetp