Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use PlumberStatic #156

Closed
chenjr0719 opened this Issue Aug 7, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@chenjr0719
Copy link

chenjr0719 commented Aug 7, 2017

As the documents says, plumber can use PlumberStatic to add and mount new static file router now.

But I can't use PlumberStatic, would you please do me a favor to solve this problem?

BTW, my plumber version is 0.4.2.

@trestletech

This comment has been minimized.

Copy link
Owner

trestletech commented Aug 22, 2017

Hi. Can I get more details on what's going wrong?

The docs you referenced are specifically for building an API programatically. If you're using the more conventional format of commenting on your functions, you might be looking for https://www.rplumber.io/docs/routing-and-input.html#static-file-handler instead

e.g. adding something like

#* @assets ./files/static /static
list()

should make the ./files/static folder accessible at the /static URL on your API.

@chenjr0719

This comment has been minimized.

Copy link
Author

chenjr0719 commented Aug 23, 2017

The directory structure is:
image

I try to run the code in doc and get the error like this:

image

That's because PlumberStatic doesn't available in this package
image

Before I reply this issue, I clone this repository and go to check the NAMESPACE, it seems that the function PlumberStatic not to be exported.

After add the comment #' @export at PlumberStatic and reinstall package, it appeared:
image

It should be worked, but actually not, I get 404 error when I visit http://127.0.0.1:8080/assets:
image

BTW, I also try your suggestion, but no luck:
image

Here is my plumber.R:

#* @assets ./myfiles /assets
list()
@trestletech

This comment has been minimized.

Copy link
Owner

trestletech commented Aug 23, 2017

Doh! Sorry, the export should be solved in #163.

I think the problem you're seeing now is related to the fact that Plumber doesn't offer directory indexes (would be a nice feature). So you won't see anything at the root of the directory, but you should see something if you go to: localhost:8080/assets/test.txt

@chenjr0719

This comment has been minimized.

Copy link
Author

chenjr0719 commented Aug 24, 2017

Oops, you are right. I can see something when I visit http://localhost:8080/assets/test.txt. That's my mistake and thanks for you to help me figure it out.

And the problem of PlumberStatic is also solved, this issue should be close.

@chenjr0719 chenjr0719 closed this Aug 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.