Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 116
Registered: ‎03-08-2011
My Device: Not Specified

Save file to a remote server

Hi all,

 

I FINALLY got the blackberry saveFile() to function properly. I can save a file to the local file system using a hardcoded given name, overwriting an existing file if it's already there. 2 questions.

 

1) Is it possible to allow the user to input the name of the file to be saved? Right now it's a *.txt file, so i'm a little weary on the extension part of it in case they decide to use a different extension which will make the file unuseable  after the save (most likely).

 

2) How can I allow the user to save the same file to a remote location? Am i still supposed to use the blackberry.io.file.saveFile API? Remote being somewhere on the web.

 

Thanks.

Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Save file to a remote server

Hi d_source.

 

Do not know which of the BB OSs your app is for, but these are starting points working with remote file transfers:

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 116
Registered: ‎03-08-2011
My Device: Not Specified

Re: Save file to a remote server

Should have specified that it's for Playbook. Thanks for the links. The PB link says that the fileTransfer option is only available for Tablet OS 2.1 (Which hasn't been released yet). I've seen other webworks apps include a save to internet type of feature in earlier versions of the Tablet OS. Is there no other way to do this?

 

Thanks.

Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Save file to a remote server

Hi d_source,

 

something must be wrong. I implemented the download and upload with these files on PB and it worked so far. If there where an update to only work with PB OS 2.1 the last commit for the PB API wouldn't be 9 month in the past. Give it a try, follow the instructions in the documentation.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 116
Registered: ‎03-08-2011
My Device: Not Specified

Re: Save file to a remote server

Will do thanks. And will report back afterward.

New Contributor
Posts: 4
Registered: ‎10-12-2012
My Device: BB10 Dev Alpha
My Carrier: Movistar

Re: Save file to a remote server

Hello, I try to use blackberry.io.filetransfer.upload on bb10 alpha but dont work for me... always fire uploadError callback with number 1. i tryed a lot of differents paths. 

 

var options = {
fileKey : "userfile",
fileName : name, //only the name of img
mimeType : "image/jpg",
chunkedMode : true,
chunkSize : 1024
};

 

blackberry.io.sandbox = false;
blackberry.io.filetransfer.upload(img, "http://www.gipegasus.com.ar/simple/uploadimg.php", uploadSuccess, uploadError, options);

 

Error code: 1 
Source: file:///accounts/1000/shared/photos/Simple.jpg 
Target: http://www.gipegasus.com.ar/simple/uploadimg.php
HTTP Status: undefined

 

Any hint?, thanks

Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: Save file to a remote server

Data ...

 

No type info is sent to a remote so you have to validate at the end-point. If you're sending images, for example, this is dead easy using an ImageMagick binding to your fave server-side language - see identify

 

The data you send is just that - a load of bytes and a tag for the name

 

Renaming ...

 

You can use HTML5 upload via XHR to post a form to the remote using AJAX. You can rename it on the server-side as you like - just send a post field with the name you want to save this upload as.

 

The upload data contains the original filename - which you can ignore if you want - a data stream and the temp filename on the server plus some other stuff

 

The server filename is random junk - something like /tmp/asdghjftsabdh and is typically short lived (deleted after the page has been handled)

 

 




Click the like button if you find my posts useful!
New Contributor
Posts: 4
Registered: ‎10-12-2012
My Device: BB10 Dev Alpha
My Carrier: Movistar

Re: Save file to a remote server

Thanks peardox, but i just copy the official example and suppose we just need to set fileName to the path for a file, in my case i wish an image, i write the code bellow and fail immediately send nothing to my server.

I write routines with a form and XHR and all work as expected, but i want not to use a form, i need to send images on the device without user selections.

Hope some help