Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to add custom "File Name" to an image/file being uploaded?

Hi xman,

We have provided you a solution that's you have asked.

So in this way you have not get it work.

That means you have some problem with basics(not with certain implementation).

That is why i willing to ask you to describe your use case which is you want to implement.

Please be clear and provide this description with screen shots.

After we understand what exactly you want to implement we will help you.

Thanks & regards.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

I though I clearly defined my issue above, but the answers I'm getting are not clear. Let me try again.

Here is my problem restated:

-----------------------------------
  • Several users will use the web file upload to upload their profile pictures and event pictures to Files collection.

  • These pictures will need to be displayed at several pages.

  • I will know the picture names. So, I'll use "imagepath" appery routine to get the path of the image to display on pages.

    But this is not working!

    For example, this is the path the "imagepath" routine returns for the image "sub_paradigmaLogo.png" (which is stored in the pre-defined collection "Files"):
    http://appery.io/app/view/e339e22c-ad...

    This path, when assigned to "asset" of image element does not display the image at all.

    The reply
    This is what Katya is suggesting:

    As you take it from Database you should use the following URL then:
    https://api.appery.io/rest/1/db/files...

    However, I know that. I know this path works, but my issues is how do I get paths to all these images which users will upload? Do you guys want me to store a path to each image in a local storage? How's that going to work with so many images I don't understand.
    -

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to add custom "File Name" to an image/file being uploaded?

Xman,

At first, here is a way to get correct URL to your image stored in Files system collection by file name:

/[fileName]?sessionToken=[userSessionToken]&masterKey=[masterKey]]https://api.appery.io/rest/1/db/files...

Note: you need to replace [databaseID] with your data base id.
and [fileName] with your fileName.

Here is an example of correct link(you can try use it in browser):
https://api.appery.io/rest/1/db/files...

Where :
52fd3d06e4b0a25c11c89917 - db id.
d0381733-4e1f-41ba-8a05-b75202988d79.customPart_201.jpeg - file name.

Take a look on this screen shot what is "fileName" here - http://i.imgur.com/DwdSmzi.png

Here is link where you can read more about "Files" system collection. http://devcenter.appery.io/documentat...

And here is what you doing wrong:
1 you've invented some not clear for us solution how to implement it. In this case we can only answer your direct questions.
2 now you ask us about why your, not clear for us solution, not work.

Currently we don't know how to store your images - thus that's your own solution and you should know it.

If i understand you correctly(cause of you did not provide us detailed use case with print screens as i asked in prev message) here is a correct solution:

1 Create collection "user_image". With fields (user(link to user) and fileName(string)).

2 On success event for "upload" service you need to create new item in "user_image" collection with current user and fileName you have received from the "upload" service.

3 When you need to get all images you just make "query" request to the "user_image" collection with filter by current user "_id". This request will return all items for current user where you can get all fileNames and with this data populate all images(on page you need).

That's all.

Regards.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

I'm not sure what's up with the tone in your replies, but not once anyone in this discussion mentioned that "imagepath" will not return correct image URL for images stored in the database (at least not clearly or directly). That, I'm now kind of getting from your reply.

The following is all I needed when I was asking - how will I get the path:

At first, here is a way to get correct URL to your image stored in Files system collection by file name:
https://api.appery.io/rest/1/db/files...
Note: you need to replace [databaseID] with your data base id.
and [fileName] with your fileName.

This could have been provided to me long ago instead of using judgmental language. I'm new to appery and this development, and there is a reason I paid up for Appery Developer Platform instead of doing hardcore bottom up programming.

Thanks anyway, I will now go and try to manually build the path to the image as suggested above.
-

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to add custom "File Name" to an image/file being uploaded?

Xman,

Sorry, i did not want to be with bad tone. If you think it so accept my apology.

I'm just think the thread should be useful for other users. And currently it has a chance to start from scratch.

But it's my bad that i didn't figure out your original use case and not provided correct solution earlier.

Would be great if you would implement your problem in you way.

Also if you willing to use our solution, don't hesitate to ask about it..

Regards.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

k, no hard feelings. I was just thinking that imagepath will give me a ready-made usable URL to the image. But, there seems to be no way around doing what you suggested above. Thanks for the suggestion, I will give it a try.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

Yurii (or anyone) can you please help me understand why the method (uploadMultipleFilesHelperWithCustomName) suggested above (which was working before for me) has stopped working after the major platform update several weeks ago?

I am now catching exception when the service runs. I tried to debug this a bit in the developer tools and found that the following code is firing:

if (isCorrectService) {
if (fileList) {
var data = new FormData();
for (var i = 0; i < fileList.length; i++) {
appendItem(data, fileList);
}
try {
datasource.execute({
'allowDataModification': false,
'processData': false,
'data': data
});
} catch (exception) {
---------- console.log(exception.name + ' ' + exception.message);
hideSpinner();
}
}

..and the exception printing the console is "illegal invocation"

This function was used in a major feature of my app (without which we are in big trouble).

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

...ping! ...anyone?

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

How to add custom "File Name" to an image/file being uploaded?

Hello!
We are working on it.
I will let you know when have more information from developers team.

xman
Posts: 0
Joined: Sun Jul 06, 2014 7:05 pm

How to add custom "File Name" to an image/file being uploaded?

Ok, thanks ...please help re-enable this feature for me ...we are a toast without it.

Return to “Issues”