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

A question about file field tipe #311

Closed
leonardorame opened this issue Feb 12, 2015 · 10 comments
Closed

A question about file field tipe #311

leonardorame opened this issue Feb 12, 2015 · 10 comments

Comments

@leonardorame
Copy link

I added a field type to one of my entities. After I click browse and select the file, the file is uploaded automatically. But it does a post to /upload route, how can I create a custom url passing the entity Id?.

for example:

.uploadInformation({url: route_of_entity + '/upload/:id'})

This should give something like: 'item/upload/21'.

Also, how can I get the route of an entity?.

@fzaninotto
Copy link
Member

@jeromemacias any insight?

@jeromemacias
Copy link
Contributor

To get a complete url for your entity you have to retrieve the baseApiUrl you previously define in your ng-admin Application configuration and retrieve entity name.

For example: .uploadInformation({url: baseApiUrl + yourEntity.name() + '/upload/:id'})

@leonardorame
Copy link
Author

Thanks @jeromemacias for writing, but the string '/upload/:id' is not replaced to the correct identifier, i.e.: /upload/123. How can I get that identifier?.

@jeromemacias
Copy link
Contributor

Mmm, exact, but how we can handle the creation part ?
I think you need to do the binding between the upload file and the entity when the form is submitting, using the filename returning by upload.

@leonardorame
Copy link
Author

@jeromemacias for now, on the creation part I forbid uploading images.

Your suggestion implies the existence of an event after upload, does anyone know which event is fired after upload?.

BTW, I don't know why the upload POST is sent just after selecting a file instead of sending the whole package on form submission.

@leonardorame
Copy link
Author

I finally store all files in an /upload directory, then, when submitting the form, there's an upload_filename param with the recently uploaded file.

Using the upload_filename param I can store it's path in my database.

@jeanlucDjeke
Copy link

Please help me . i develop an admin page for a website and i don't now how to upload image with ng-admin

@hmendes00
Copy link

I have the same problem as @jeanlucDjeke .
Can anyone help us with that?

here's my code:

companies.creationView()
.fields([
nga.field('name')
.validation({ required: true }),
nga.field('logo', 'file').uploadInformation({
'fileName': nga.field('name') + '.png',
'url': (baseurl + 'companies/logos'),
'method': 'PUT'})

]);

but do I need to put some server-side code?
how can I see the image?

thank you, guys.

@hmendes00
Copy link

Hi Jean,

Actually I don't have a server side for that.. I can't find a place to do
that.
I was hoping someone could come up with an explanation about how to do an
upload using ng-admin properly.

=/

On Thu, Mar 10, 2016 at 12:23 PM, Jean-Luc DJEKE notifications@github.com
wrote:

Thanks you for your answer.
Yes .please if you can, put your server side code(i use an api built with
slim in php) and how to see the image


Reply to this email directly or view it on GitHub
#311 (comment).

Att,
Hugo S. Mendes

Analista de Sistemas

ITIL® V3 Foundation
55.81-9910.1992

@jeanlucDjeke
Copy link

ok thank you.I hope someone else did it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants