You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Gaurav Sachdeva <ga...@ymail.com.INVALID> on 2017/09/22 03:58:07 UTC

SlingPostServlet File Upload Section Documentation Needs an Update

Hello,
The following has been mentioned in the documentation regarding the algorithm used for selecting the primary node type of the file uploaded - 
"If a @TypeHint suffixed parameter is not present or the value does not denote an existing non-mixin node type, the node will be created as an nt:file node if the parent node is of type nt:folder. Otherwise the node will be created with primary node type nt:resource."

However, while playing around, I found it to be slightly different - 
The primary node type also depends on the "name" attribute of the <input type="file"> tag. If the input tag has a name attribute which is NOT *, for example, name="image", then the node is created with a name "image" and it has properties jcr:data, jcr:lastModified and jcr:mimeType. However, is the name attribute is *, name="*", then it doesn't matter whether the parent node is of type nt:folder or something else, the node for uploaded file is always created with node type as nt:file only.
Regards,Gaurav

Re: SlingPostServlet File Upload Section Documentation Needs an Update

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Thu, Oct 5, 2017 at 10:40 AM, Gaurav Sachdeva
<ga...@ymail.com.invalid> wrote:
> ..I have updated the file and created a Pull Request for the same...

Thanks, I have commented at https://github.com/apache/sling-site/pull/2

-Bertrand

Re: SlingPostServlet File Upload Section Documentation Needs an Update

Posted by Gaurav Sachdeva <ga...@ymail.com.INVALID>.
 Hi Robert,
I have updated the file and created a Pull Request for the same.
Regards,Gaurav
    On Wednesday 4 October 2017, 1:46:45 PM IST, Robert Munteanu <ro...@apache.org> wrote:  
 
 Hi Gaurav,

On Fri, 2017-09-22 at 03:58 +0000, Gaurav Sachdeva wrote:
> Hello,
> The following has been mentioned in the documentation regarding the
> algorithm used for selecting the primary node type of the file
> uploaded - 
> "If a @TypeHint suffixed parameter is not present or the value does
> not denote an existing non-mixin node type, the node will be created
> as an nt:file node if the parent node is of type nt:folder. Otherwise
> the node will be created with primary node type nt:resource."
> 
> However, while playing around, I found it to be slightly different - 
> The primary node type also depends on the "name" attribute of the
> <input type="file"> tag. If the input tag has a name attribute which
> is NOT *, for example, name="image", then the node is created with a
> name "image" and it has properties jcr:data, jcr:lastModified and
> jcr:mimeType. However, is the name attribute is *, name="*", then it
> doesn't matter whether the parent node is of type nt:folder or
> something else, the node for uploaded file is always created with
> node type as nt:file only.
> Regards,Gaurav

Thanks for the report. Could you send a pull request with this update?

The sling site is found in Github at https://github.com/apache/sling-si
te and the page you referenced is https://github.com/apache/sling-site/
blob/master/src/main/jbake/content/documentation/bundles/manipulating-
content-the-slingpostservlet-servlets-post.md .

Robert

Re: SlingPostServlet File Upload Section Documentation Needs an Update

Posted by Robert Munteanu <ro...@apache.org>.
Hi Gaurav,

On Fri, 2017-09-22 at 03:58 +0000, Gaurav Sachdeva wrote:
> Hello,
> The following has been mentioned in the documentation regarding the
> algorithm used for selecting the primary node type of the file
> uploaded - 
> "If a @TypeHint suffixed parameter is not present or the value does
> not denote an existing non-mixin node type, the node will be created
> as an nt:file node if the parent node is of type nt:folder. Otherwise
> the node will be created with primary node type nt:resource."
> 
> However, while playing around, I found it to be slightly different - 
> The primary node type also depends on the "name" attribute of the
> <input type="file"> tag. If the input tag has a name attribute which
> is NOT *, for example, name="image", then the node is created with a
> name "image" and it has properties jcr:data, jcr:lastModified and
> jcr:mimeType. However, is the name attribute is *, name="*", then it
> doesn't matter whether the parent node is of type nt:folder or
> something else, the node for uploaded file is always created with
> node type as nt:file only.
> Regards,Gaurav

Thanks for the report. Could you send a pull request with this update?

The sling site is found in Github at https://github.com/apache/sling-si
te and the page you referenced is https://github.com/apache/sling-site/
blob/master/src/main/jbake/content/documentation/bundles/manipulating-
content-the-slingpostservlet-servlets-post.md .

Robert