Upload file along with aspect properties
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2010 06:10 PM
I can upload files to Alfresco 3.4 using the web script
alfresco/service/api/upload
but now I have added an custom aspect to Alfresco, is there any way to set properties from this aspect when a file is uploaded ? Or even afterwards.
Hopefully I am missing something because I can't see how to set bespoke properties on file uploaded via a web script.
Thanks,
Guy.
alfresco/service/api/upload
but now I have added an custom aspect to Alfresco, is there any way to set properties from this aspect when a file is uploaded ? Or even afterwards.
Hopefully I am missing something because I can't see how to set bespoke properties on file uploaded via a web script.
Thanks,
Guy.
Labels:
- Labels:
-
Archive
8 REPLIES 8

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2010 03:18 AM
You can:
1) Set a business rule which applies the aspect to all uploaded file (of a certain space). Each time you upload a file, Alfresco will apply the aspect for you and then you modify aspect properties using Alfresco Explorer
2) write a new web script which:
- uploads the file
- applies the aspect to the file
- modify the properties of the aspect (e.g. taking values from a form)
1) Set a business rule which applies the aspect to all uploaded file (of a certain space). Each time you upload a file, Alfresco will apply the aspect for you and then you modify aspect properties using Alfresco Explorer
2) write a new web script which:
- uploads the file
- applies the aspect to the file
- modify the properties of the aspect (e.g. taking values from a form)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2010 07:15 AM
Good, I'll write a new web script that adds the aspect and sets the properties.
I don't know how many other people are trying to use the REST API without Share, but applying an aspect to an uploaded file must be a common requirement.
Thanks,
Guy.
I don't know how many other people are trying to use the REST API without Share, but applying an aspect to an uploaded file must be a common requirement.
Thanks,
Guy.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2010 09:05 AM
Yes a rule is a good way to approach this. Customising the webscript can of course be done, but it currently involves overriding the entire controller script for upload.post.js. We are looking at this area (and many others!) to improve extensibility in Share/REST APIs for the next major release.
Cheers,
Kev
Cheers,
Kev
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2010 11:21 AM
Kevin,
Thanks for your reply,
I understand you cautioning against using a Web Script to set aspect properties after file upload, but I can't use the Alfresco Java Server Faces client because our application only uses Alfresco for part of its functionality.
Guy.
Thanks for your reply,
I understand you cautioning against using a Web Script to set aspect properties after file upload, but I can't use the Alfresco Java Server Faces client because our application only uses Alfresco for part of its functionality.
Guy.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2010 06:16 PM
The Javascript webscript
webscripts/org/alfresco/repository/upload/upload.post.js
checks for a list of aspect names and adds them if supplied. So I can duplicate the script, rename it and use that. So full marks to who ever wrote the script int he first place.
webscripts/org/alfresco/repository/upload/upload.post.js
checks for a list of aspect names and adds them if supplied. So I can duplicate the script, rename it and use that. So full marks to who ever wrote the script int he first place.
// Additional aspects? if (aspects.length > 0) { for (i = 0; i < aspects.length; i++) { newFile.addAspect(aspects[i]); newFile.save(); } }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2011 07:31 AM
Good - i'll pass along your comments

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2011 07:46 AM
newFile.addAspect -> This adds the aspect.
1) What I need to do to set the value of that new aspect ?
2) And how can I add my custom aspect ?
Do I need to change the contentModel ? I tried it but it gives errors when I restart the server.
Thanks in advance,
Sanket Mehta.
1) What I need to do to set the value of that new aspect ?
2) And how can I add my custom aspect ?
Do I need to change the contentModel ? I tried it but it gives errors when I restart the server.
Thanks in advance,
Sanket Mehta.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2013 01:53 AM
hi..
reference with your post…can u upload a file along with aspect properties????
for this did you changed the content model..?
can you please explain me about your code..
actually i have the requirement in this topic..
please provide me the source code..
thanking you..
reference with your post…can u upload a file along with aspect properties????
for this did you changed the content model..?
can you please explain me about your code..
actually i have the requirement in this topic..
please provide me the source code..
thanking you..
