How to get all files from Gallery without using s3eImagePicker in Marmalade? - ios

I have requirement to get all files from Gallery and show thumbnail of actual image file in Grid Layout for selection. In this case I cannot use s3eImagePicker as it opens Gallery application in which I cannot add my button. Basically my application requirement is show all images in Gallery to user in thumbnail form. When user select any thumbnail and press UpLoad button I need to copy actual image from Gallery to application folder selected by user. So my UI contains Grid Layout for thumbnail,List of Target Folders and two buttons i.e Cancel and Upload. This kind of UI is not possible with s3eImagePicket. So I am searching for other solution which can give path info of all files in Gallery.
Please note that I am developing application for iPad and Android.
Marmalade Team Member: Can you pls reply on this? For Contact I can read from device without using Default Contact application, but it is not possible for Gallery. Can you please raise this as new feature if posisble and if there is no solution exist for this?

In marmalade if you are searching for the path of all files in a directory (e.g. a gallery directory), here is one way to get that:
std::string strDirectory = "[GALLERY PATH HERE]";
s3eFileList *pFileList = s3eFileListDirectory( strDirectory.c_str() );
if( pFileList == NULL )
{
return;
}
char pFileName[255];
int32 iFileNameLen( 255 );
while( s3eFileListNext( pFileList,
pFileName,
iFileNameLen ) == S3E_RESULT_SUCCESS )
{
s3eDeviceYield(); // use this yield if there are potentially many files
std::string strImagePath = strDirectory + pFileName;
...
do whatever you want now with your paths for files in gallery
...
}
s3eFileListClose( pFileList );

Related

How images are mapped in Contao news Extension?

I am doing a newsmigration to latest Contao 4.
Can anyone please explain how the image files are related to tl_news table ?
Currently for my migration I have imagepath and imagename for the respective image.
When I add an image to a news in contao through backend. The following fields get updated in database.
addImage => 1,
singleSRC => f52a3871946211e782662e3e7a222c66
But when I search singleSRC in tl_files.uuid , it doesn't show any records.
Please help me to find how the images can be mapped during migration to Contao 4
The singleSRC field in tl_news (and also tl_content and tl_calendar_events for example) is a binary field containing an UUID that relates to the tl_files.uuid field.
I do not know how exactly you implemented your news migration script. But within the Contao framework, this is how you get the path to a file from singleSRC for example:
// $objNews is a \Contao\NewsModel object
$objFile = \Contao\FilesModel::findByUuid($objNews->singleSRC);
$strPath = $objFile->path;
And this is how you would add it back to the new news entry somewhere else:
// $strPath contains the relative path of the file on the other installation
$objFile = \Contao\Dbafs::addResource($strPath);
$objNews->singleSRC = $objFile->uuid;

Resource Directory Path Issue in iOS

3.2 for developing a game.I have developed game in android but facing a problem in iOS i.e
I am facing problem to read resource images.In my game have 3 stages "Simple","Medium" and "Hard".I have put images on the following path
# "Simple/1.png","Medium/1.png","Hard/1.png"
# "Simple/2.png","Medium/2.png","Hard/2.png"
# ------------------------------------------
# ------------------------------------------
# "Simple/n.png","Medium/n.png","Hard/n.png"
In android getting correct image by using full path of image.
But in iOS it is not working.
How i can fetch image of same name from different directory in iOS.
You should probably use FileUtils::addSearchPath() and add "Simple", "Medium" or "Hard", depending on the game stage and then you can use just "1.png" to refer to the file from various Cocos2d-x APIs.
landge,
Please try this:
See my screenshot using cocos2d-x-3.6
http://prntscr.com/7zwty9
It shows Xcode with 3 files with the same name 1.png in different absolute directories: hard/medium/simple.
vector<string> searchPaths = fu->getSearchPaths();
fu->addSearchPath("res/medium");
CCLOG("fpff = %s", fu->fullPathForFilename("1.png").c_str());
This is the console output:
fpff = /Users/javier.fuchs/Library/Developer/CoreSimulator/Devices/68F9EE6B-2829-420E-9359-00EC30C6372D/data/Containers/Bundle/Application/E586FE31-AFC2-4052-9826-9B27AA75182A/MyCppGame iOS.app/res/medium/1.png
Please make sure where is the file, and take a look of the full path, inside the project.
There is no guaranty with search paths, even if you doing:
auto& list = fu->getSearchPaths();
for( const auto &item : list) {
CCLOG("%s", item.c_str());
}
You will see that adding a relative path that does not exist, the relative path will be included anyway.

Cocoa/iOS: How to add a file as attachment to a PDF document?

PDF files support embedding arbitrary files as attachments (see here).
I would like to do just that in a Mac and an iPhone application using Objective-C:
Add a file as attachment to a PDF
Read the list of attached files from a PDF and extract one
Use case:
My app uses a custom document format that can only be opened by the app. I'd like to export the document as PDF and embed the original, custom document so that users who happen to have the app installed can modify the document. Everybody else can still open and print the PDF.
You can do this easily with the iOS version of the Debenu Quick PDF Library. Download the sample project and modify it with the sample code below:
How to embed a file
[DQPL LoadFromFile:path_of_my_PDF_file :#""]; //load your existing PDF file
[DQPL EmbedFile:#"Original_custom_document" :path_of_the_original_custom_document :#""]; //specify the name and the location of the attachment
[DQPL SaveToFile:new_path];
How to find the filenames of the attachments (skip if you have only one attached file)
[DQPL LoadFromFile:new_path :#""];
NSString *listItem;
int fileCount = [DQPL EmbeddedFileCount]; //returns the number of attached files
for( int count = 1; count <= fileCount; count++ ){
listItem = [DQPL GetEmbeddedFileStrProperty:count :1]; //returns the filename of the attached file
//show/read or save the returned filenames and the index of it...
}
How to extract an attached file
[DQPL LoadFromFile:new_path :#""];
[DQPL GetEmbeddedFileContentToFile:1 :path_and_filename_to_write_the_extracted_attachment]; //specify where do you want to save the extracted attachment (in this case the index of the attachment is 1)
Pal
(Debenu Team)

Multiple input file tags with IOS 6+ on iPad/iPhone

EDIT :
I've been able to resolve this, after finding that iOS uploads every image as "image.jpg". In freeASPUpload.asp, I changed the following :
For Each fileItem In UploadedFiles.Items
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & FileName, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
Next
To :
For Each fileItem In UploadedFiles.Items
FileName = GetFileName(path, fileItem.FileName)
fileItem.FileName = FileName
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & FileName, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
Next
This is within the save function of the script. The GetFileName function iterates over what is in the folder already, and adds a number until it is unique. It then updates the file key to its new name. I've left an "image.jpg" file in the temp folder, so that it always finds one. That works for now.
What I've found, however, is for some reason, it flips the second photo out of the five that the form allows for..
I will try to fix that / look for others with the same issue. I've always had problems with iPhones and iPads rotating pictures, and it's never consistent.
I'm trying to grab multiple files from a mobile fleet of iPads and iPhones. Currently I have 5
<input type="file" name="fileX" accept="image/*">
This works fine in a browser (using free asp upload / classic ASP). In testing, it works with IOS, but only if I send one file. If I send more then one via the form, I get the error 'file not found'. It seems like the files aren't being sent at all.
The file not found kicks back when trying to manipulate the file via FSO.
Uploads here :
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
SaveFiles = ""
uploadsDirVar = "directory"
Upload.Save(uploadsDirVar)
ks = Upload.UploadedFiles.keys
Errors out here :
Set f=fs.GetFile(uploadsDirVar & "\" & Upload.UploadedFiles(fileKey).FileName)
Any ideas on how I can get around this? Everything I've read points towards the HTML5 multiple tag on a single input. However, in my scenario, this won't work. I'm also tying descriptions for the images to the fields based on field name, restricting the upload to 5, re-sizing the images on the action page before passing it to its final destination and attaching them to an email.
Any advice welcome, and thank you for your time!
**Edit
The issue seems to be that IOS names all uploads "image", coming from either the camera or the library. Now the problem is how to rename the image before the script attempts to upload it. From what I'm understanding, it needs to happen within the asp upload component before it places the file.
See the above edit for the answer. As for the flipped images - turns out they are flipped straight from the iPad. I checked the exif data and I'm not sure how to account for this in my system. If I find the answer, I'll post here.

Linking a .doc file on a mvc view page

For something which seems so simple I can't find a solution, I have a word .doc file which I want to be linked on one of my pages so that a user can click on a link and open/download it (whichever is easier) and then read it on the machine with MS word.
Right now I have it in my content folder and tried to display it in both an and but no luck.
Is this an issue of IIS or just I'm going about this all wrong?
Present dir setup:-
Solution>Project>Content>File.doc
Solution>Project>Views>Home>NewRecord.cshtml
File location 1st followed by page I'm trying to display file on.
If I understand your problem correctly that you want to make User to Click and he/she will be promoted to download the .doc then.....
You can achieve with submit button which will be styled with CSS as LINK, then you perform the HTTP GET to the server within HTML form tag, Form will target the action on Server, which will return FileContentResult,
public FileContentResult GetWordDocument(string Id)
{
var contentDisposition = new ContentDisposition
{
FileName = "WordDoc.doc",
Inline = false;
};
FileContentResult documentResult= File(secureDoc.SecuredFileBytes,"application/msword", contentDisposition.FileName);
documentResult.ExecuteResult(this.ControllerContext);
return documentResult;
}
Content-Disposition:What are the differences between "inline" and "attachment"?
http://msdn.microsoft.com/en-us/library/system.web.mvc.filecontentresult(v=vs.108).aspx
Hope this will help to resolve.

Resources