-
Notifications
You must be signed in to change notification settings - Fork 0
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
Error Authorization Required #1
Comments
Can you please try sending the acces token in the authorization header and
let me know if that works?
…On Fri, Jun 1, 2018, 22:01 bellgetlinks ***@***.***> wrote:
Hi I figure out how to upload file to s3 to sub folder and I found this :)
By the way I trying upload file and I add access_token={token} but always
get 401 error
Example : POST
"/api/consumers/{id}/images/{folder}/files/upload?access_token={token}"
I dont know why :(
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFggn9KpZGe_JflXFwo7LFHE1gBEiTpcks5t4Y99gaJpZM4UXK2J>
.
|
it's not working :( |
I think I know what the issue is. "acls": [
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW",
"property": [
"__upload__images"
]
}
] Please notice the property "__upload__images" in which images is the name of the realation you gave between the consumer and the images model in the consumers json file. |
You can also start by enabling all acl actions on the consumers model and see if that works |
Thanks for your advice, It looks like the error is gone but I found another problem Seem like s3 generate new folder by using userId :/ And nothing create in images model after upload file |
Good to hear! |
I will try to set uo a sample project tommrow for you to use |
You need to give in the description the file name e.g. screenshot.png that works for me using postman |
As to the ACL, you need to have in the consumers.json file the following relation "relations": {
"images": {
"type": "hasOne",
"model": "Image",
"foreignKey": "userId"
}
} Combined with the ACL "acls": [
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW",
"property": [
"__upload__images"
]
}
] it should work. You must provide and access token of the consumer for it to work in my case as we gave the permission to the owner of the current consumer instance. This works for both providing the access token in the header or as a query param... If this still doesnt work for you please post all relevant configuration files so I can see what went wrong |
Thanks you for your help but It's not working yet. I will start a new project to test first and will try what is wrong :) |
Sure thing keep me posted and share a link to the test project so i can debug it myself |
Sorry for late this is my repository for test https://bitbucket.org/bellsenawat/loopback-test-s3-upload/src/master/ Again still not working, S3 still upload to a new folder by using userId And another question As you set relation of user to images is "hasOne" and I want to set to "hasMany" it can be ? |
I never figured that the user ID was the issue... This is an intended
behavior as the folder belongs to that user...
As to has many relation i didn't try but this library came to solve the
isolation of folders per user... If you want to contribute you are more
than welcome.
…On Sat, Jun 2, 2018, 21:29 bellgetlinks ***@***.***> wrote:
Sorry for late this is my repository for test
https://bitbucket.org/bellsenawat/loopback-test-s3-upload/src/master/
<http://url>
Again still not working, S3 still upload to a new folder by using userId
And another question As you set relation of user to images is "hasOne" and
I want to set to "hasMany" it can be ?
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFggn1xKXBmYmANn5gxOdgcTtf7UFXyuks5t4tl9gaJpZM4UXK2J>
.
|
So for each user have their folder image in s3 right ? |
Yrs each user has their own folder and only they have access to it.
Current behavior doesn't return anything. The issue is that the model isn't
suppose to know how it was accessed thus not suppose to return the url to
the file it created but you can easily add an operation hook in your model
to change that behavior or better yet create a pull request that implements
that feature!
…On Sat, Jun 2, 2018, 21:47 bellgetlinks ***@***.***> wrote:
So for each user have their folder image in s3 right ?
But I confuse why nothing happened in images model and after i upload
images nothing return back may be it can be url or something :/
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFggnyZhdSbmbEe9xWcQlZrTc0dA95pcks5t4t2vgaJpZM4UXK2J>
.
|
Hi I figure out how to upload file to s3 to sub folder and I found this :)
By the way I trying upload file and I add access_token={token} but always get 401 error
Example : POST "/api/consumers/{id}/images/{folder}/files/upload?access_token={token}"
I dont know why :(
The text was updated successfully, but these errors were encountered: